Class: IB::Messages::AbstractMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/ib/messages/abstract_message.rb

Overview

This is just a basic generic message from the server.

Class variables: Instance attributes (at least):

Version:

    • int: current version of message format.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



41
42
43
# File 'lib/ib/messages/abstract_message.rb', line 41

def created_at
  @created_at
end

#dataObject

Returns the value of attribute data.



41
42
43
# File 'lib/ib/messages/abstract_message.rb', line 41

def data
  @data
end

Class Method Details

.data_mapObject

Class methods



16
17
18
# File 'lib/ib/messages/abstract_message.rb', line 16

def self.data_map # Map for converting between structured message and raw data
  @data_map ||= []
end

.message_idObject



24
25
26
# File 'lib/ib/messages/abstract_message.rb', line 24

def self.message_id
  @message_id
end

.message_typeObject

Returns message type Symbol (e.g. :OpenOrderEnd)



29
30
31
# File 'lib/ib/messages/abstract_message.rb', line 29

def self.message_type
  to_s.split(/::/).last.to_sym
end

.versionObject

Per class, minimum message version supported



20
21
22
# File 'lib/ib/messages/abstract_message.rb', line 20

def self.version # Per class, minimum message version supported
  @version || 1
end

Instance Method Details

#message_idObject



33
34
35
# File 'lib/ib/messages/abstract_message.rb', line 33

def message_id
  self.class.message_id
end

#message_typeObject



37
38
39
# File 'lib/ib/messages/abstract_message.rb', line 37

def message_type
  self.class.message_type
end

#to_humanObject



43
44
45
46
47
48
49
50
# File 'lib/ib/messages/abstract_message.rb', line 43

def to_human
  "<#{self.message_type}:" +
  @data.map do |key, value|
    unless [:version].include?(key)
      " #{key} #{ value.is_a?(Hash) ? value.inspect : value}"
    end
  end.compact.join(',') + " >"
end