Class: GreenButtonClasses::UsagePoint

Inherits:
GreenButtonEntry show all
Defined in:
lib/greenbutton/gb_classes.rb

Instance Attribute Summary collapse

Attributes inherited from GreenButtonEntry

#href_from_parent, #other_related, #related_hrefs

Instance Method Summary collapse

Methods inherited from GreenButtonEntry

#add_related_link, #all_rules, #assign_rule, #create_attributes, #entry_node, #find_by_href, #get_related_links, #initialize

Constructor Details

This class inherits a constructor from GreenButtonClasses::GreenButtonEntry

Instance Attribute Details

#electric_power_quality_summariesObject

Returns the value of attribute electric_power_quality_summaries


145
146
147
# File 'lib/greenbutton/gb_classes.rb', line 145

def electric_power_quality_summaries
  @electric_power_quality_summaries
end

#electric_power_usage_summariesObject

Returns the value of attribute electric_power_usage_summaries


145
146
147
# File 'lib/greenbutton/gb_classes.rb', line 145

def electric_power_usage_summaries
  @electric_power_usage_summaries
end

#green_buttonObject

Returns the value of attribute green_button


145
146
147
# File 'lib/greenbutton/gb_classes.rb', line 145

def green_button
  @green_button
end

#local_time_parametersObject

Returns the value of attribute local_time_parameters


145
146
147
# File 'lib/greenbutton/gb_classes.rb', line 145

def local_time_parameters
  @local_time_parameters
end

#meter_readingsObject

Returns the value of attribute meter_readings


145
146
147
# File 'lib/greenbutton/gb_classes.rb', line 145

def meter_readings
  @meter_readings
end

Instance Method Details

#add_related_entry(type, parser) ⇒ Object


159
160
161
162
163
164
165
166
167
168
# File 'lib/greenbutton/gb_classes.rb', line 159

def add_related_entry(type, parser)
  case type
  when 'local_time_parameters'
    self.local_time_parameters = parser
  when 'meter_reading', 'electric_power_usage_summary', 'electric_power_quality_summary'
    self.send(Helper.pluralize(type)) << parser
  else 
    warn 'Not a recognized relation for UsagePoint: ' + type
  end
end

#additional_rulesObject


170
171
172
# File 'lib/greenbutton/gb_classes.rb', line 170

def additional_rules
  { service_kind: Rule.new(:service_kind, ".//ServiceCategory/kind", :ServiceKind) }
end

#customer_idObject


174
175
176
177
178
179
180
# File 'lib/greenbutton/gb_classes.rb', line 174

def customer_id
  if @customer_id.nil?
    match = /\/([^\/]+)\/UsagePoint/i.match(self.href)
    @customer_id = match.nil? ? nil : match[1]
  end
  @customer_id
end

#docObject


155
156
157
# File 'lib/greenbutton/gb_classes.rb', line 155

def doc
  self.green_button.doc
end

#end_timeObject


192
193
194
195
196
197
198
199
200
# File 'lib/greenbutton/gb_classes.rb', line 192

def end_time
  end_time = self.meter_readings[0].interval_blocks[0].end_time
  self.meter_readings.each do |mr|
    mr.interval_blocks.each do |ib|
      end_time = [ib.end_time, end_time].max
    end
  end 
  end_time
end

#pre_rule_assignment(parent) ⇒ Object


148
149
150
151
152
153
# File 'lib/greenbutton/gb_classes.rb', line 148

def pre_rule_assignment(parent)
  self.green_button = parent
  self.meter_readings = []
  self.electric_power_quality_summaries = []
  self.electric_power_usage_summaries = []
end

#start_timeObject


182
183
184
185
186
187
188
189
190
# File 'lib/greenbutton/gb_classes.rb', line 182

def start_time
  start_time = Time.now
  self.meter_readings.each do |mr|
    mr.interval_blocks.each do |ib|
      start_time = [ib.start_time, start_time].min
    end
  end
  start_time
end