Class: URBANopt::Reporting::DefaultReports::Generator
- Inherits:
-
Object
- Object
- URBANopt::Reporting::DefaultReports::Generator
- Defined in:
- lib/urbanopt/reporting/default_reports/generator.rb
Overview
Onsite generator system attributes
Instance Attribute Summary collapse
-
#size_kw ⇒ Object
Float - power capacity in kilowatts.
Class Method Summary collapse
-
.add_generator(existing_generator, new_generator) ⇒ Object
Merge Generator systems.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Generator
constructor
Initialize Generator attributes from a hash.
-
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization.
Constructor Details
#initialize(hash = {}) ⇒ Generator
Initialize Generator attributes from a hash. Generator attributes currently are limited to power capacity.
- parameters:
-
hash
- Hash - A hash containing a:size_kw
key/value pair which represents the nameplate capacity in kilowatts (kW)
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/urbanopt/reporting/default_reports/generator.rb', line 28 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } @size_kw = hash[:size_kw] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema # initialize @@logger @@logger ||= URBANopt::Reporting::DefaultReports.logger end |
Instance Attribute Details
#size_kw ⇒ Object
Float - power capacity in kilowatts
19 20 21 |
# File 'lib/urbanopt/reporting/default_reports/generator.rb', line 19 def size_kw @size_kw end |
Class Method Details
.add_generator(existing_generator, new_generator) ⇒ Object
Merge Generator systems
54 55 56 57 58 59 60 61 62 |
# File 'lib/urbanopt/reporting/default_reports/generator.rb', line 54 def self.add_generator(existing_generator, new_generator) if existing_generator.size_kw.nil? && new_generator.size_kw.nil? existing_generator.size_kw = nil else existing_generator.size_kw = (existing_generator.size_kw || 0) + (new_generator.size_kw || 0) end return existing_generator end |
Instance Method Details
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization
44 45 46 47 48 49 |
# File 'lib/urbanopt/reporting/default_reports/generator.rb', line 44 def to_hash result = {} result[:size_kw] = @size_kw if @size_kw return result end |