Class: UserData
- Inherits:
-
Object
- Object
- UserData
- Defined in:
- lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/userdata_enums.rb
Direct Known Subclasses
UserDataBoolean, UserDataFiles, UserDataHVACBldgType, UserDataNonTradableLightsCategory, UserDataSHWBldgType, UserDataWWRBldgType
Class Method Summary collapse
- .boolean_to_string(value) ⇒ Object
-
.compare(one, another) ⇒ Boolean
Compare the two UserData enums are the same or not.
-
.get_constant_values ⇒ Object
Static method that retrieves the function constant values in a list.
-
.matched_any?(user_data) ⇒ Boolean
Static method to check if a user data matches to any of the constant value.
Class Method Details
.boolean_to_string(value) ⇒ Object
36 37 38 39 40 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/userdata_enums.rb', line 36 def self.boolean_to_string(value) return value if value.nil? || value.is_a?(Numeric) # For consistency in further comparison value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value.to_s : value end |
.compare(one, another) ⇒ Boolean
Compare the two UserData enums are the same or not. Static method.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/userdata_enums.rb', line 23 def self.compare(one, another) return false if one.nil? || another.nil? one_value = boolean_to_string(one) another_value = boolean_to_string(another) if one_value.is_a?(String) && another_value.is_a?(String) return one_value.strip.downcase == another_value.strip.downcase else return one_value == another_value end end |
.get_constant_values ⇒ Object
Static method that retrieves the function constant values in a list
3 4 5 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/userdata_enums.rb', line 3 def self.get_constant_values return constants.map(&method(:const_get)) end |
.matched_any?(user_data) ⇒ Boolean
Static method to check if a user data matches to any of the constant value
11 12 13 14 15 16 17 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/userdata_enums.rb', line 11 def self.matched_any?(user_data) userdata_constants = get_constant_values userdata_constants.each do |constant| return true if compare(user_data, constant) end return false end |