Class: URBANopt::Reporting::DefaultReports::ThermalStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/reporting/default_reports/thermal_storage.rb

Overview

Ice Thermal Storage Systems

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ ThermalStorage

Returns a new instance of ThermalStorage.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 26

def initialize(hash = {})
  hash.delete_if { |k, v| v.nil? }

  @its_size = hash[:its_size_kwh]
  @ptes_size = hash[:ptes_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

#its_size_kwhObject

Float - Total ice storage capacity on central plant loop in kWh



20
21
22
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 20

def its_size_kwh
  @its_size_kwh
end

#ptes_size_kwhObject

Float - Total ice storage capacity distributed to packaged systems in kWh



24
25
26
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 24

def ptes_size_kwh
  @ptes_size_kwh
end

Class Method Details

.add_values(existing_value, new_value) ⇒ Object

Add up old and new values



65
66
67
68
69
70
71
72
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 65

def self.add_values(existing_value, new_value) #:nodoc:
  if existing_value && new_value
    existing_value += new_value
  elsif new_value
    existing_value = new_value
  end
  return existing_value
end

.merge_thermal_storage(existing_tes, new_tes) ⇒ Object

Merge thermal storage



77
78
79
80
81
82
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 77

def self.merge_thermal_storage(existing_tes, new_tes)
  existing_tes.its_size_kwh = add_values(existing_tes.its_size_kwh, new_tes.its_size_kwh)
  existing_tes.ptes_size_kwh = add_values(existing_tes.ptes_size_kwh, new_tes.ptes_size_kwh)

  return existing_tes
end

Instance Method Details

#defaultsObject

Assigns default values if attribute values do not exist.



43
44
45
46
47
48
49
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 43

def defaults
  hash = {}
  hash[:its_size_kwh] = nil
  hash[:ptes_size_kwh] = nil

  return hash
end

#to_hashObject

Convert to hash equivalent for JSON serialization



54
55
56
57
58
59
60
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 54

def to_hash
  result = {}
  result[:its_size_kwh] = @its_size_kwh if @its_size_kwh
  result[:ptes_size_kwh] = @ptes_size_kwh if @ptes_size_kwh

  return result
end