Class: Dtn::Lookups::Request

Inherits:
Object
  • Object
show all
Includes:
Concerns::Id
Defined in:
lib/dtn/lookups/request.rb

Overview

Lookups are used to get historical data from IQFeed’s lookup socket. This class returns historical data as the return value from the function used to request the data.

Works synchronously

For more details see: www.iqfeed.net/dev/api/docs/HistoricalviaTCPIP.cfm

Constant Summary collapse

END_OF_MESSAGE_CHARACTERS =
/!ENDMSG!/.freeze
NO_DATA_CHARACTERS =
/!NO_DATA!/.freeze
SYNTAX_ERROR_CHARACTERS =
/!SYNTAX_ERROR!/.freeze
PORT =
9100

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Id

#id

Instance Attribute Details

#combined_optionsObject

Returns the value of attribute combined_options.



28
29
30
# File 'lib/dtn/lookups/request.rb', line 28

def combined_options
  @combined_options
end

Class Method Details

.call(*args, **opts, &blk) ⇒ Object



23
24
25
# File 'lib/dtn/lookups/request.rb', line 23

def call(*args, **opts, &blk)
  new.call(*args, **opts, &blk)
end

Instance Method Details

#call(&blk) ⇒ Object

Initialize the request to api, should be used in children classes only



33
34
35
36
37
38
39
# File 'lib/dtn/lookups/request.rb', line 33

def call(*, &blk)
  socket.print "#{format(self.class.const_get(:TEMPLATE), combined_options)}\r\n"

  pull_socket(&blk)

  return result_accumulator unless block_given?
end