Class: CapitalIQ::ApiResponse::IdentifierResultGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/capital-iq/api_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ IdentifierResultGroup

Returns a new instance of IdentifierResultGroup.



5
6
7
8
9
# File 'lib/capital-iq/api_response.rb', line 5

def initialize(identifier)
  @identifier = identifier
  @header_map = {}
  @results = []
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/capital-iq/api_response.rb', line 4

def identifier
  @identifier
end

Instance Method Details

#<<(result) ⇒ Object



10
11
12
13
14
# File 'lib/capital-iq/api_response.rb', line 10

def <<(result)
  raise "Result contains wrong identifier" if result.Identifier != self.identifier
  @results << result
  (result.Headers || []).each { |h| @header_map[h] = result }
end

#[](header) ⇒ Object



19
20
21
# File 'lib/capital-iq/api_response.rb', line 19

def [](header)
  @header_map[header][header]
end

#headersObject



15
16
17
# File 'lib/capital-iq/api_response.rb', line 15

def headers
  @header_map.keys
end

#to_hashObject



23
24
25
# File 'lib/capital-iq/api_response.rb', line 23

def to_hash
  Hash[self.headers.collect { |h| [h, self[h]] }]
end

#to_sObject



27
28
29
# File 'lib/capital-iq/api_response.rb', line 27

def to_s
  to_hash().to_s()
end