Sha256: 82b890dafbee6aa4f485f5fe6523fac6ed9b51b7e63fd4d630a7373ff6624e77
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 KB
Contents
# ********************************************************************************* # URBANopt (tm), Copyright (c) Alliance for Sustainable Energy, LLC. # See also https://github.com/urbanopt/urbanopt-reporting-gem/blob/develop/LICENSE.md # ********************************************************************************* require 'json' require 'json-schema' module URBANopt module Reporting module DefaultReports ## # Onsite generator system attributes ## class Generator ## # _Float_ - power capacity in kilowatts # attr_accessor :size_kw ## # 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) # 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::Reporting::DefaultReports.logger end ## # Convert to a Hash equivalent for JSON serialization ## def to_hash result = {} result[:size_kw] = @size_kw if @size_kw return result end ## # Merge Generator systems ## 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 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems