Class: Infostrada::Phase
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- Infostrada::Phase
- Defined in:
- lib/infostrada/phase.rb
Overview
Phase of a given edition.
The only thing that can be confusing is the current and currents boolean variables. Here’s an explanation from the Infostrada API website:
* b_Current: this boolean field describes the current phase. This field can be True for only
one phase.
* b_Currents: this boolean field describes the current phases. More than one phases can be
True, e.g. multiple groups in the Champions League.
You can only get a list of phases on Infostradas GetPhaseList endpoint.
Constant Summary collapse
- URL =
'/GetPhaseList'
Constants inherited from BaseRequest
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#currents ⇒ Object
Returns the value of attribute currents.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#id ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#name ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase1_id ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase1_name ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase2_id ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase2_name ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase3_id ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#phase3_name ⇒ Object
Returns the value of attribute phase3_name.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#table ⇒ Object
Get the classification table for this phase.
Class Method Summary collapse
Instance Method Summary collapse
- #has_table? ⇒ Boolean
-
#initialize(hash) ⇒ Phase
constructor
A new instance of Phase.
Methods inherited from BaseRequest
Constructor Details
#initialize(hash) ⇒ Phase
Returns a new instance of Phase.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/infostrada/phase.rb', line 39 def initialize(hash) @id = hash['n_PhaseID'] @name = hash['c_Phase'] @short_name = hash['c_PhaseShort'] @phase1_id = hash['n_Phase1ID'] @phase1_name = hash['c_Phase1'] @phase2_id = hash['n_Phase2ID'] @phase2_name = hash['c_Phase2'] @phase3_id = hash['n_Phase3ID'] @phase3_name = hash['c_Phase3'] @has_table = hash['b_Table'] @current = hash['b_Current'] @currents = hash['b_Currents'] # On GetPhaseList endpoint dates are just yyymmdd. Example: 20100629 (which translates to # 2010-06-29). if hash['n_DateStart'] && hash['n_DateEnd'] @start_date = Date.parse(hash['n_DateStart'].to_s) @end_date = Date.parse(hash['n_DateEnd'].to_s) end self end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def current @current end |
#currents ⇒ Object
Returns the value of attribute currents.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def currents @currents end |
#end_date ⇒ Object
Returns the value of attribute end_date.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def end_date @end_date end |
#id ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def id @id end |
#name ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def name @name end |
#phase1_id ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def phase1_id @phase1_id end |
#phase1_name ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def phase1_name @phase1_name end |
#phase2_id ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def phase2_id @phase2_id end |
#phase2_name ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def phase2_name @phase2_name end |
#phase3_id ⇒ Object
Short name is only set outside GetPhaseList endpoint. For example on match list.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def phase3_id @phase3_id end |
#phase3_name ⇒ Object
Returns the value of attribute phase3_name.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def phase3_name @phase3_name end |
#short_name ⇒ Object
Returns the value of attribute short_name.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def short_name @short_name end |
#start_date ⇒ Object
Returns the value of attribute start_date.
19 20 21 |
# File 'lib/infostrada/phase.rb', line 19 def start_date @start_date end |
#table ⇒ Object
Get the classification table for this phase.
35 36 37 |
# File 'lib/infostrada/phase.rb', line 35 def table @table end |
Class Method Details
.where(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/infostrada/phase.rb', line 21 def self.where( = {}) edition_id = .delete(:edition_id) list = get!(URL, query: { editionid: edition_id.to_i }) phases = [] list.each do |phase_hash| phases << Phase.new(phase_hash) end phases end |
Instance Method Details
#has_table? ⇒ Boolean
63 64 65 |
# File 'lib/infostrada/phase.rb', line 63 def has_table? @has_table end |