Class: Helper::EstimatedCostPotentialSavingHelper
- Inherits:
-
Object
- Object
- Helper::EstimatedCostPotentialSavingHelper
- Defined in:
- lib/helper/estimated_cost_potential_saving_helper.rb
Instance Method Summary collapse
- #estimated_cost(lighting_cost_current, heating_cost_current, hot_water_cost_current) ⇒ Object
- #potential_saving(lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, estimated_cost = BigDecimal(0)) ⇒ Object
Instance Method Details
#estimated_cost(lighting_cost_current, heating_cost_current, hot_water_cost_current) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/helper/estimated_cost_potential_saving_helper.rb', line 7 def estimated_cost( lighting_cost_current, heating_cost_current, hot_water_cost_current ) estimated_cost = [ lighting_cost_current, heating_cost_current, hot_water_cost_current, ].compact.map { |value| BigDecimal(value) }.sum sprintf("%.2f", estimated_cost) end |
#potential_saving(lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, estimated_cost = BigDecimal(0)) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/helper/estimated_cost_potential_saving_helper.rb', line 21 def potential_saving( lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, estimated_cost = BigDecimal(0) ) potential_saving_sum = [ lighting_cost_potential, heating_cost_potential, hot_water_cost_potential, ].compact.map { |value| BigDecimal(value) }.sum potential_saving = BigDecimal(estimated_cost) - potential_saving_sum sprintf("%.2f", potential_saving) end |