Class: GreenButtonData::Entry

Inherits:
Object
  • Object
show all
Includes:
Fetchable, Utilities
Defined in:
lib/green-button-data/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attributes_to_hash, #class_from_name, #epoch_to_time, #first_sunday_of, #last_weekday_of, #normalize_epoch, #nth_weekday_of, #parse_datetime, #weekday_offset

Methods included from Fetchable

included

Constructor Details

#initialize(attributes) ⇒ Entry

Returns a new instance of Entry.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/green-button-data/entry.rb', line 9

def initialize(attributes)
  # Automagically sets instance variables from attribute hash parsed from
  # the GreenButtonData::Parser classes
  init_instance_vars attributes

  # Handle relations via related_urls
  @related_urls.is_a?(Hash) and @related_urls.each do |key, value|
    self.instance_variable_set :"@#{key}_url", value
    singleton_class.class_eval do
      attr_accessor "#{key}_url".to_sym
    end

    # Define accessor methods from pluralized resource names
    define_attr_accessors key
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/green-button-data/entry.rb', line 6

def id
  @id
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/green-button-data/entry.rb', line 7

def token
  @token
end

#usage_point_idObject (readonly)

Returns the value of attribute usage_point_id.



6
7
8
# File 'lib/green-button-data/entry.rb', line 6

def usage_point_id
  @usage_point_id
end