class DoverToCalais::ResponseData::Event
Attributes
entities[R]
Public Class Methods
new(events_hash)
click to toggle source
# 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
Public Instance Methods
[](attrib_name)
click to toggle source
# 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_pair() { |a, instance_variable_get| ... }
click to toggle source
# 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