Class: DoverToCalais::ResponseData::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/dover_to_calais.rb

Overview

class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events_hash) ⇒ Event

Returns a new instance of Event.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/dover_to_calais.rb', line 102

def initialize(events_hash)
  # @entities = entity_hash
  events_hash.each do |k,v|
    unless k.eql?('_typeGroup') || k.eql?('instances') || k.eql?('_typeReference')
      k = 'type' if k.eql?('_type') #don't like the underscore
      ## create and initialize an instance variable for this key/value pair
      self.instance_variable_set("@#{k}", v)
      ## create the getter that returns the instance variable
      self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})
      ## create the setter that sets the instance variable
      self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})
    end
  end #block
end

Instance Attribute Details

#entitiesObject (readonly)

Returns the value of attribute entities.



100
101
102
# File 'lib/dover_to_calais.rb', line 100

def entities
  @entities
end

Instance Method Details

#[](attrib_name) ⇒ Object



123
124
125
126
127
128
129
# File 'lib/dover_to_calais.rb', line 123

def [](attrib_name)
  self.instance_variables.each do |a|
    if "@#{a}" == attrib_name
      self.instance_variable_get(a)
    end
  end
end

#each_pairObject

method



117
118
119
120
121
# File 'lib/dover_to_calais.rb', line 117

def each_pair
  self.instance_variables.each do |a|
    yield a, self.instance_variable_get(a)
  end
end