Class: URBANopt::Reporting::DefaultReports::Storage
- Inherits:
-
Object
- Object
- URBANopt::Reporting::DefaultReports::Storage
- Defined in:
- lib/urbanopt/reporting/default_reports/storage.rb
Overview
Onsite storage system attributes
Instance Attribute Summary collapse
-
#size_kw ⇒ Object
Float - power capacity in kilowatts.
-
#size_kwh ⇒ Object
Float - storage capacity in kilowatt-hours.
Class Method Summary collapse
-
.add_storage(existing_storage, new_storage) ⇒ Object
Merge Storage systems.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Storage
constructor
Initialize Storage attributes from a hash.
-
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization.
Constructor Details
#initialize(hash = {}) ⇒ Storage
Initialize Storage attributes from a hash. Storage attributes currently are limited to power and storage capacity.
- parameters:
-
hash
- Hash - A hash containing:size_kw
and:size_kwh
key/value pair which represents the power and storage capacity in kilowatts (kW) and kilowatt-hours respectively.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 33 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } @size_kw = hash[:size_kw] @size_kwh = hash[:size_kwh] # 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/storage.rb', line 19 def size_kw @size_kw end |
#size_kwh ⇒ Object
Float - storage capacity in kilowatt-hours
24 25 26 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 24 def size_kwh @size_kwh end |
Class Method Details
.add_storage(existing_storage, new_storage) ⇒ Object
Merge Storage systems
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 62 def self.add_storage(existing_storage, new_storage) if existing_storage.size_kw.nil? existing_storage.size_kw = new_storage.size_kw else existing_storage.size_kw = (existing_storage.size_kw || 0) + (new_storage.size_kw || 0) end if existing_storage.size_kw.nil? existing_storage.size_kwh = new_storage.size_kwh else existing_storage.size_kwh = (existing_storage.size_kwh || 0) + (new_storage.size_kwh || 0) end return existing_storage end |
Instance Method Details
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization
50 51 52 53 54 55 56 57 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 50 def to_hash result = {} result[:size_kw] = @size_kw if @size_kw result[:size_kwh] = @size_kwh if @size_kwh return result end |