source-code/screens/energy-work-power-screens/energy_efficiency_screen.rb
def energy_efficiency_screen
    @heading = 'Energy efficiency = (useful energy output / energy input) x 100'
    background('images/energy_work_power_large.png')

    # Energy efficiency screen header
    ScreenHeader.new(self, '/title_screen/energy_work_power_screen', @@font, @heading)

    # Energy efficiency screen content
    flow(:height => 640, :width => 1080, :scroll => true) do
      # Left margin offset
      stack(:height => 640, :width => 80) do
      end
      # Content column
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Useful energy output')
        flow do
          @useful_energy_output = ScreenEditLine.new(self, @@font, @heading)
          @useful_energy_output_unit = para(strong(' J'))
          @useful_energy_output_unit.style(@@screen_unit_text_styles)
        end

        ScreenLabel.new(self, @@font, @heading, 'Energy input')
        flow do
          @energy_input = ScreenEditLine.new(self, @@font, @heading)
          @energy_input_unit = para(strong(' J'))
          @energy_input_unit.style(@@screen_unit_text_styles)
        end

        @calculate = button('Calculate')

        @result_display = flow

        @error_display = flow

        @calculate.click do
          @result_display.clear do
            @result = Joules.energy_efficiency(@useful_energy_output.text.to_f,
                                               @energy_input.text.to_f)
            @energy_efficiency = para(@result.to_s)
            @energy_efficiency_unit = para(' %')
            @energy_efficiency.style(@@screen_result_text_styles)
            @energy_efficiency_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
# Draws the energy efficiency screen on the Shoes app window.
Draws the energy efficiency screen on the Shoes app window.
Draws the energy efficiency screen on the Shoes app window .
def energy_efficiency_screen
    @heading = 'Energy efficiency = (useful energy output / energy input) x 100'
    background('images/energy_work_power_large.png')
    ScreenHeader.new(self, '/title_screen/energy_work_power_screen', @@font, @heading)
    flow(:height => 640, :width => 1080, :scroll => true) do
      stack(:height => 640, :width => 80) do
      end
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Useful energy output')
        flow do
          @useful_energy_output = ScreenEditLine.new(self, @@font, @heading)
          @useful_energy_output_unit = para(strong(' J'))
          @useful_energy_output_unit.style(@@screen_unit_text_styles)
        end
        ScreenLabel.new(self, @@font, @heading, 'Energy input')
        flow do
          @energy_input = ScreenEditLine.new(self, @@font, @heading)
          @energy_input_unit = para(strong(' J'))
          @energy_input_unit.style(@@screen_unit_text_styles)
        end
        @calculate = button('Calculate')
        @result_display = flow
        @error_display = flow
        @calculate.click do
          @result_display.clear do
            @result = Joules.energy_efficiency(@useful_energy_output.text.to_f,
                                               @energy_input.text.to_f)
            @energy_efficiency = para(@result.to_s)
            @energy_efficiency_unit = para(' %')
            @energy_efficiency.style(@@screen_result_text_styles)
            @energy_efficiency_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
def energy_efficiency_screen @heading = 'Energy efficiency = (useful energy output / energy input) x 100' background ( 'images/energy_work_power_large.png' ) ScreenHeader . new ( self , '/title_screen/energy_work_power_screen' , @@font , @heading ) flow ( :height => 640 , :width => 1080 , :scroll => true ) do stack ( :height => 640 , :width => 80 ) do end stack ( :height => 640 , :width => 1000 ) do ScreenLabel . new ( self , @@font , @heading , 'Useful energy output' ) flow do @useful_energy_output = ScreenEditLine . new ( self , @@font , @heading ) @useful_energy_output_unit = para ( strong ( ' J' ) ) @useful_energy_output_unit . style ( @@screen_unit_text_styles ) end ScreenLabel . new ( self , @@font , @heading , 'Energy input' ) flow do @energy_input = ScreenEditLine . new ( self , @@font , @heading ) @energy_input_unit = para ( strong ( ' J' ) ) @energy_input_unit . style ( @@screen_unit_text_styles ) end @calculate = button ( 'Calculate' ) @result_display = flow @error_display = flow @calculate . click do @result_display . clear do @result = Joules . energy_efficiency ( @useful_energy_output . text . to_f , @energy_input . text . to_f ) @energy_efficiency = para ( @result . to_s ) @energy_efficiency_unit = para ( ' %' ) @energy_efficiency . style ( @@screen_result_text_styles ) @energy_efficiency_unit . style ( @@screen_result_text_styles ) end end end end end
Draws the energy efficiency screen on the Shoes app window.
Draws the energy efficiency screen on the Shoes app window .
# Energy efficiency screen header # Energy efficiency screen content # Left margin offset # Content column