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 containting:size_kwand:size_kwhkey/value pair which represents the power and storage capacity in kilowatts (kW) and kilowatt-hours respectively.
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 68 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
54 55 56 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 54 def size_kw @size_kw end |
#size_kwh ⇒ Object
Float - storage capacity in kilowatt-hours
59 60 61 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 59 def size_kwh @size_kwh end |
Class Method Details
.add_storage(existing_storage, new_storage) ⇒ Object
Merge Storage systems
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 97 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
85 86 87 88 89 90 91 92 |
# File 'lib/urbanopt/reporting/default_reports/storage.rb', line 85 def to_hash result = {} result[:size_kw] = @size_kw if @size_kw result[:size_kwh] = @size_kwh if @size_kwh return result end |