Class: IB::Datatypes::AbstractDatum

Inherits:
Object
  • Object
show all
Defined in:
lib/ib-ruby/datatypes.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributeHash = nil) ⇒ AbstractDatum

If a hash is given, keys are taken as attribute names, values as data. The attrs of the instance are set automatically from the attributeHash.

If no hash is given, #init is called in the instance. #init should set the datum up in a generic state.



40
41
42
43
44
45
46
47
48
49
# File 'lib/ib-ruby/datatypes.rb', line 40

def initialize(attributeHash=nil)
  if attributeHash.nil?
    init
  else
    raise(ArgumentError.new("Argument must be a Hash")) unless attributeHash.is_a?(Hash)
    attributeHash.keys.each {|key|
      self.send((key.to_s + "=").to_sym, attributeHash[key])
    }
  end
end

Instance Method Details

#initObject



30
31
32
# File 'lib/ib-ruby/datatypes.rb', line 30

def init
  @created_at = Time.now
end