Class: Reuters::Client::Search::Equity

Inherits:
Base
  • Object
show all
Defined in:
lib/reuters/client/search/equity.rb

Overview

Note:

All Equity Search XML Requests require that the appropriate xmlns attribute is present on elements inside the request element. This class uses the before_request hook to inject the appropriate attribute.

Performs a Equity Search Reuters API request. Equity searches are intended to vary in complexity but allow you to retrieve financial information about a company on a specific exchange.

Instance Method Summary collapse

Methods inherited from Base

#after_request, #before_request, #client, #method_missing, #request

Constructor Details

#initializeEquity

Returns a new instance of Equity.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/reuters/client/search/equity.rb', line 15

def initialize
  # process equity request objects before they are sent.
  before_request do |req|

    if req.key?(:query_header)
      req.attributes({ query_header: { 'xmlns' => data_type } }, false)
    end

    [:filter, :query].each do |section|
      if req.key?(section)

        sec = req.send(section)

        sec.keys.each do |key|
          sec.attributes({ key => { 'xmlns' => query_spec } }, false)
          sec[key].keys.each do |type|
            sec[key].attributes({ type => { 'xmlns' => data_type } }, false)
          end
        end

      end
    end

    req
  end

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Reuters::Client::Base

Instance Method Details

#data_typeString

Retrieve the correctly formatted Namespace Data Type for an Equity-based Search Reuters Request.

Returns:

  • (String)

    the fully resolved namespace endpoint.



48
49
50
# File 'lib/reuters/client/search/equity.rb', line 48

def data_type
  ns_definition(:query_spec_datatypes)
end

#query_specString

Retrieve the correctly formatted Namespace Query Specification for an Equity-based Search.

Returns:

  • (String)

    the fully resolved namespace endpoint.



56
57
58
# File 'lib/reuters/client/search/equity.rb', line 56

def query_spec
  ns_definition(:equity_quote, :query_spec, 1)
end