Module: PropertyDataCalculator
- Included in:
- CrePropertyMatcher::PropertyMatcher
- Defined in:
- lib/cre_property_matcher/property_data_calculator.rb
Instance Method Summary collapse
- #get_average_by_attribute(properties, attribute) ⇒ Object
- #get_average_by_reference_property_state(properties, reference, attribute) ⇒ Object
- #get_average_by_reference_property_state_and_property_type(properties, reference, attribute) ⇒ Object
- #get_average_for_all_by_property_type(properties, attribute, property_type) ⇒ Object
Instance Method Details
#get_average_by_attribute(properties, attribute) ⇒ Object
20 21 22 23 |
# File 'lib/cre_property_matcher/property_data_calculator.rb', line 20 def get_average_by_attribute(properties, attribute) values_array = get_attribute_from_properties(properties, attribute) float_average_of_array(values_array) end |
#get_average_by_reference_property_state(properties, reference, attribute) ⇒ Object
4 5 6 7 |
# File 'lib/cre_property_matcher/property_data_calculator.rb', line 4 def get_average_by_reference_property_state(properties, reference, attribute) state_properties = filter_properties_by_state(properties, reference.state) get_average_by_attribute(state_properties, attribute) end |
#get_average_by_reference_property_state_and_property_type(properties, reference, attribute) ⇒ Object
9 10 11 12 13 |
# File 'lib/cre_property_matcher/property_data_calculator.rb', line 9 def get_average_by_reference_property_state_and_property_type(properties, reference, attribute) state_properties = filter_properties_by_state(properties, reference.state) filtered_properties = filter_properties_by_property_type(state_properties, reference.general_property_type) get_average_by_attribute(filtered_properties, attribute) end |
#get_average_for_all_by_property_type(properties, attribute, property_type) ⇒ Object
15 16 17 18 |
# File 'lib/cre_property_matcher/property_data_calculator.rb', line 15 def get_average_for_all_by_property_type(properties, attribute, property_type) filtered_properties = filter_properties_by_property_type(properties, property_type) get_average_by_attribute(filtered_properties, attribute) end |