Class: HeatingSystemCalculator::BaseItemFinder
- Inherits:
-
Object
- Object
- HeatingSystemCalculator::BaseItemFinder
show all
- Defined in:
- app/services/heating_system_calculator/base_item_finder.rb
Instance Method Summary
collapse
Instance Method Details
#get_number_of_poles_from_consolidated_elements(elements) ⇒ Object
18
19
20
21
|
# File 'app/services/heating_system_calculator/base_item_finder.rb', line 18
def get_number_of_poles_from_consolidated_elements(elements)
elements.to_a.sum { |e| (Item::DOUBLE_POLE_VOLTAGES.include?(e['volts'].round(1)) || e['amps'] > 15.0 ? 2 : 1).round * e['qty'] }
end
|
#get_total_from_solution(elements, attribute_key) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/services/heating_system_calculator/base_item_finder.rb', line 3
def get_total_from_solution(elements, attribute_key)
tot = 0.0
elements.each do |elem|
qty = 1.0
qty = elem['qty'].to_f if elem['qty'].to_f > 1.0
tot += (elem[attribute_key].to_f * qty)
end
tot
end
|