Class: URBANopt::Scenario::DefaultReports::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/scenario/default_reports/generator.rb

Overview

Onsite generator system attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Generator

Intialize Generator attributes from a hash. Generator attributes currently are limited to power capacity.

parameters:
  • hash - Hash - A hash containting a :size_kw key/value pair which represents the nameplate capacity in kilowatts (kW)



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/urbanopt/scenario/default_reports/generator.rb', line 53

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::Scenario::DefaultReports.logger
end

Instance Attribute Details

#size_kwObject

Float - power capacity in kilowatts



44
45
46
# File 'lib/urbanopt/scenario/default_reports/generator.rb', line 44

def size_kw
  @size_kw
end

Class Method Details

.add_generator(existing_generator, new_generator) ⇒ Object

Merge Generator systems



80
81
82
83
84
85
86
87
88
# File 'lib/urbanopt/scenario/default_reports/generator.rb', line 80

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_hashObject

Convert to a Hash equivalent for JSON serialization



69
70
71
72
73
74
75
# File 'lib/urbanopt/scenario/default_reports/generator.rb', line 69

def to_hash
  result = {}

  result[:size_kw] = @size_kw if @size_kw

  return result
end