Class: IB::IncomingMessages::AbstractMessage

Inherits:
ExtremelyAbstractMessage show all
Defined in:
lib/ib-ruby/messages.rb

Overview

This is just a basic generic message from the server.

Class variables: @@message_id - integer message id.

Instance attributes: :data - Hash of actual data read from a stream.

Override the load(socket) method in your subclass to do actual reading into @data.

Instance Attribute Summary collapse

Attributes inherited from ExtremelyAbstractMessage

#created_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExtremelyAbstractMessage

#to_human

Constructor Details

#initialize(socket, server_version) ⇒ AbstractMessage

Returns a new instance of AbstractMessage.

Raises:

  • (Exception)


817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
# File 'lib/ib-ruby/messages.rb', line 817

def initialize(socket, server_version)
  raise Exception.new("Don't use AbstractMessage directly; use the subclass for your specific message type") if self.class.name == "AbstractMessage"
  #logger.debug(" * loading #{self.class.name}")
  @created_at = Time.now

  @data = Hash.new
  @socket = socket
  @server_version = server_version

  self.load()

  @socket = nil


  #logger.debug(" * New #{self.class.name}: #{ self.to_human }")
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



810
811
812
# File 'lib/ib-ruby/messages.rb', line 810

def data
  @data
end

Class Method Details

.inherited(by) ⇒ Object



834
835
836
837
# File 'lib/ib-ruby/messages.rb', line 834

def AbstractMessage.inherited(by)
  super(by)
  Classes.push(by)
end

.message_idObject



812
813
814
# File 'lib/ib-ruby/messages.rb', line 812

def self.message_id
  raise Exception("AbstractMessage.message_id called - you need to override this in a subclass.")
end

Instance Method Details

#loadObject

Raises:

  • (Exception)


839
840
841
# File 'lib/ib-ruby/messages.rb', line 839

def load
  raise Exception.new("Don't use AbstractMessage; override load() in a subclass.")
end