Class: Infostrada::Table

Inherits:
BaseRequest show all
Includes:
Enumerable
Defined in:
lib/infostrada/table.rb

Constant Summary collapse

URL =
'/GetTable'

Constants inherited from BaseRequest

BaseRequest::RETRIES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRequest

get!

Constructor Details

#initialize(phase_id, table_list) ⇒ Table

Returns a new instance of Table.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/infostrada/table.rb', line 17

def initialize(phase_id, table_list)
  @phase_id = phase_id

  @entries = []
  table_list.each do |hash|
    @edition_id ||= hash['n_EditionID']
    @entries << TableEntry.new(hash)
  end

  self
end

Instance Attribute Details

#edition_idObject

Returns the value of attribute edition_id.



5
6
7
# File 'lib/infostrada/table.rb', line 5

def edition_id
  @edition_id
end

#entriesObject

Returns the value of attribute entries.



5
6
7
# File 'lib/infostrada/table.rb', line 5

def entries
  @entries
end

#phase_idObject

Returns the value of attribute phase_id.



5
6
7
# File 'lib/infostrada/table.rb', line 5

def phase_id
  @phase_id
end

Class Method Details

.where(options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/infostrada/table.rb', line 9

def self.where(options = {})
  phase_id = options.delete(:phase_id)

  list = get!(URL, query: { phaseid: phase_id })

  table = Table.new(phase_id, list)
end

Instance Method Details

#each(&block) ⇒ Object



29
30
31
# File 'lib/infostrada/table.rb', line 29

def each(&block)
  @entries.each(&block)
end