Class: Infostrada::Table
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- Infostrada::Table
- Includes:
- Enumerable
- Defined in:
- lib/infostrada/table.rb
Constant Summary collapse
- URL =
'/GetTable'
Constants inherited from BaseRequest
Instance Attribute Summary collapse
-
#edition_id ⇒ Object
Returns the value of attribute edition_id.
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#phase_id ⇒ Object
Returns the value of attribute phase_id.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(phase_id = nil, table_list = [], &block) ⇒ Table
constructor
A new instance of Table.
Methods inherited from BaseRequest
Constructor Details
#initialize(phase_id = nil, table_list = [], &block) ⇒ Table
Returns a new instance of Table.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/infostrada/table.rb', line 26 def initialize(phase_id = nil, table_list = [], &block) @phase_id = phase_id @entries = [] table_list.each do |hash| @edition_id ||= hash['n_EditionID'] @entries << TableEntry.new(hash) if hash['n_TeamID'] end block.call(self) if block_given? self end |
Instance Attribute Details
#edition_id ⇒ Object
Returns the value of attribute edition_id.
5 6 7 |
# File 'lib/infostrada/table.rb', line 5 def edition_id @edition_id end |
#entries ⇒ Object
Returns the value of attribute entries.
5 6 7 |
# File 'lib/infostrada/table.rb', line 5 def entries @entries end |
#phase_id ⇒ Object
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
.from_json(json = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/infostrada/table.rb', line 16 def self.from_json(json = {}) self.new do |table| table.phase_id = json['phase_id'] table.edition_id = json['edition_id'] table.entries = json['entries'].map{ |entry| TableEntry.from_json(entry) } end end |
.where(options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/infostrada/table.rb', line 9 def self.where( = {}) phase_id = .delete(:phase_id) list = get!(URL, query: { phaseid: phase_id }) new(phase_id, list) end |
Instance Method Details
#as_json(options = {}) ⇒ Object
39 40 41 42 |
# File 'lib/infostrada/table.rb', line 39 def as_json( = {}) hash = super hash = { 'phase_id' => phase_id, 'edition_id' => edition_id, 'entries' => hash } end |
#each(&block) ⇒ Object
44 45 46 |
# File 'lib/infostrada/table.rb', line 44 def each(&block) @entries.each(&block) end |