Class: URBANopt::Reporting::DefaultReports::Wind
- Inherits:
-
Object
- Object
- URBANopt::Reporting::DefaultReports::Wind
- Defined in:
- lib/urbanopt/reporting/default_reports/wind.rb
Overview
Onsite wind system attributes
Instance Attribute Summary collapse
-
#average_yearly_energy_produced_kwh ⇒ Object
Float - power capacity in kilowatts.
-
#size_class ⇒ Object
Float - power capacity in kilowatts.
-
#size_kw ⇒ Object
Float - power capacity in kilowatts.
Class Method Summary collapse
-
.add_wind(existing_wind, new_wind) ⇒ Object
Merge Wind systems.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Wind
constructor
Initialize Wind attributes from a hash.
-
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization.
Constructor Details
#initialize(hash = {}) ⇒ Wind
Initialize Wind attributes from a hash. Wind 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 40 41 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 28 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } @size_kw = hash[:size_kw] @avg_energy_kwh = hash[:average_yearly_energy_produced_kwh] @size_class = hash[:size_class] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema # initialize @@logger @@logger ||= URBANopt::Reporting::DefaultReports.logger end |
Instance Attribute Details
#average_yearly_energy_produced_kwh ⇒ Object
Float - power capacity in kilowatts
19 20 21 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 19 def average_yearly_energy_produced_kwh @average_yearly_energy_produced_kwh end |
#size_class ⇒ Object
Float - power capacity in kilowatts
19 20 21 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 19 def size_class @size_class end |
#size_kw ⇒ Object
Float - power capacity in kilowatts
19 20 21 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 19 def size_kw @size_kw end |
Class Method Details
.add_wind(existing_wind, new_wind) ⇒ Object
Merge Wind systems
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 59 def self.add_wind(existing_wind, new_wind) if existing_wind.size_kw.nil? && new_wind.size_kw.nil? existing_wind.size_kw = nil else existing_wind.size_kw = (existing_wind.size_kw || 0) + (new_wind.size_kw || 0) end if existing_wind.average_yearly_energy_produced_kwh.nil? && new_wind.average_yearly_energy_produced_kwh.nil? existing_wind.average_yearly_energy_produced_kwh = nil else existing_wind.average_yearly_energy_produced_kwh = (existing_wind.average_yearly_energy_produced_kwh || 0) + (new_wind.average_yearly_energy_produced_kwh || 0) end return existing_wind end |
Instance Method Details
#to_hash ⇒ Object
Convert to a Hash equivalent for JSON serialization
46 47 48 49 50 51 52 53 54 |
# File 'lib/urbanopt/reporting/default_reports/wind.rb', line 46 def to_hash result = {} result[:size_kw] = @size_kw if @size_kw result[:average_yearly_energy_produced_kwh] = @avg_energy_kwh if @avg_energy_kwh result[:size_class] = @size_class if @size_class return result end |