Class: URBANopt::Reporting::DefaultReports::EndUse
- Inherits:
-
Object
- Object
- URBANopt::Reporting::DefaultReports::EndUse
- Defined in:
- lib/urbanopt/reporting/default_reports/end_use.rb
Overview
Enduse class all enduse energy consumption results.
Instance Attribute Summary collapse
-
#cooling ⇒ Object
Returns the value of attribute cooling.
-
#exterior_equipment ⇒ Object
Returns the value of attribute exterior_equipment.
-
#exterior_lighting ⇒ Object
Returns the value of attribute exterior_lighting.
-
#fans ⇒ Object
Returns the value of attribute fans.
-
#generators ⇒ Object
Returns the value of attribute generators.
-
#heat_recovery ⇒ Object
Returns the value of attribute heat_recovery.
-
#heat_rejection ⇒ Object
Returns the value of attribute heat_rejection.
-
#heating ⇒ Object
Returns the value of attribute heating.
-
#humidification ⇒ Object
Returns the value of attribute humidification.
-
#interior_equipment ⇒ Object
Returns the value of attribute interior_equipment.
-
#interior_lighting ⇒ Object
Returns the value of attribute interior_lighting.
-
#pumps ⇒ Object
Returns the value of attribute pumps.
-
#refrigeration ⇒ Object
Returns the value of attribute refrigeration.
-
#water_systems ⇒ Object
Returns the value of attribute water_systems.
Instance Method Summary collapse
-
#defaults ⇒ Object
Assign default values if values does not exist.
-
#initialize(hash = {}) ⇒ EndUse
constructor
EndUse class intialize all enduse atributes:
:heating,:cooling,:interior_lighting,:exterior_lighting,:interior_equipment,:exterior_equipment,:fans,:pumps,:heat_rejection,:humidification,:heat_recovery,:water_systems,:refrigeration,:generators. -
#merge_end_use!(new_end_use) ⇒ Object
Aggregate values of each EndUse attribute.
-
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization.
Constructor Details
#initialize(hash = {}) ⇒ EndUse
EndUse class intialize all enduse atributes: :heating , :cooling , :interior_lighting , :exterior_lighting , :interior_equipment , :exterior_equipment , :fans , :pumps , :heat_rejection , :humidification , :heat_recovery , :water_systems , :refrigeration , :generators
- parameters:
-
hash- Hash - A hash which may contain a deserialized end_use.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 52 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } hash = defaults.merge(hash) @heating = hash[:heating] @cooling = hash[:cooling] @interior_lighting = hash[:interior_lighting] @exterior_lighting = hash[:exterior_lighting] @interior_equipment = hash[:interior_equipment] @exterior_equipment = hash[:exterior_equipment] @fans = hash[:fans] @pumps = hash[:pumps] @heat_rejection = hash[:heat_rejection] @humidification = hash[:humidification] @heat_recovery = hash[:heat_recovery] @water_systems = hash[:water_systems] @refrigeration = hash[:refrigeration] @generators = hash[:generators] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema end |
Instance Attribute Details
#cooling ⇒ Object
Returns the value of attribute cooling.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def cooling @cooling end |
#exterior_equipment ⇒ Object
Returns the value of attribute exterior_equipment.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def exterior_equipment @exterior_equipment end |
#exterior_lighting ⇒ Object
Returns the value of attribute exterior_lighting.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def exterior_lighting @exterior_lighting end |
#fans ⇒ Object
Returns the value of attribute fans.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def fans @fans end |
#generators ⇒ Object
Returns the value of attribute generators.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def generators @generators end |
#heat_recovery ⇒ Object
Returns the value of attribute heat_recovery.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def heat_recovery @heat_recovery end |
#heat_rejection ⇒ Object
Returns the value of attribute heat_rejection.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def heat_rejection @heat_rejection end |
#heating ⇒ Object
Returns the value of attribute heating.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def heating @heating end |
#humidification ⇒ Object
Returns the value of attribute humidification.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def humidification @humidification end |
#interior_equipment ⇒ Object
Returns the value of attribute interior_equipment.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def interior_equipment @interior_equipment end |
#interior_lighting ⇒ Object
Returns the value of attribute interior_lighting.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def interior_lighting @interior_lighting end |
#pumps ⇒ Object
Returns the value of attribute pumps.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def pumps @pumps end |
#refrigeration ⇒ Object
Returns the value of attribute refrigeration.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def refrigeration @refrigeration end |
#water_systems ⇒ Object
Returns the value of attribute water_systems.
41 42 43 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 41 def water_systems @water_systems end |
Instance Method Details
#defaults ⇒ Object
Assign default values if values does not exist
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 79 def defaults hash = {} hash[:heating] = nil hash[:cooling] = nil hash[:interior_lighting] = nil hash[:exterior_lighting] = nil hash[:interior_equipment] = nil hash[:exterior_equipment] = nil hash[:fans] = nil hash[:pumps] = nil hash[:heat_rejection] = nil hash[:humidification] = nil hash[:heat_recovery] = nil hash[:water_systems] = nil hash[:refrigeration] = nil hash[:generators] = nil return hash end |
#merge_end_use!(new_end_use) ⇒ Object
Aggregate values of each EndUse attribute.
- Parameters:
-
new_end_use- EndUse - An object of EndUse class.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 138 def merge_end_use!(new_end_use) @heating += new_end_use.heating if new_end_use.heating @cooling += new_end_use.cooling if new_end_use.cooling @interior_lighting += new_end_use.interior_lighting if new_end_use.interior_lighting @exterior_lighting += new_end_use.exterior_lighting if new_end_use.exterior_lighting @interior_equipment += new_end_use.interior_equipment if new_end_use.interior_equipment @exterior_equipment += new_end_use.exterior_equipment if new_end_use.exterior_equipment @fans += new_end_use.fans if new_end_use.fans @pumps += new_end_use.pumps if new_end_use.pumps @heat_rejection += new_end_use.heat_rejection if new_end_use.heat_rejection @humidification += new_end_use.humidification if new_end_use.humidification @heat_recovery += new_end_use.heat_recovery if new_end_use.heat_recovery @water_systems += new_end_use.water_systems if new_end_use.water_systems @refrigeration += new_end_use.refrigeration if new_end_use.refrigeration @generators += new_end_use.generators if new_end_use.generators return self end |
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization.
-
Exclude attributes with nil values.
-
Validate end_use hash properties against schema.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/urbanopt/reporting/default_reports/end_use.rb', line 106 def to_hash result = {} result[:heating] = @heating result[:cooling] = @cooling result[:interior_lighting] = @interior_lighting result[:exterior_lighting] = @exterior_lighting result[:interior_equipment] = @interior_equipment result[:exterior_equipment] = @exterior_equipment result[:fans] = @fans result[:pumps] = @pumps result[:heat_rejection] = @heat_rejection result[:humidification] = @humidification result[:heat_recovery] = @heat_recovery result[:water_systems] = @water_systems result[:refrigeration] = @refrigeration result[:generators] = @generators # validate end_use properties against schema if @@validator.validate(@@schema[:definitions][:EndUse][:properties], result).any? raise "end_use properties does not match schema: #{@@validator.validate(@@schema[:definitions][:EndUse][:properties], result)}" end return result end |