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
Short name is only set outside GetPhaseList endpoint.
-
#currents ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#end_date ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#has_table ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#id ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#level ⇒ 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
Short name is only set outside GetPhaseList endpoint.
-
#short_name ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#start_date ⇒ Object
Short name is only set outside GetPhaseList endpoint.
-
#table ⇒ Object
Get the classification table for this phase.
Class Method Summary collapse
-
.from_json(json = {}) ⇒ Object
Useful method to get a Phase object from a json serialized Phase object.
- .where(options = {}) ⇒ Object
Instance Method Summary collapse
- #has_table? ⇒ Boolean
-
#initialize(hash = {}, &block) ⇒ Phase
constructor
A new instance of Phase.
Methods inherited from BaseRequest
Constructor Details
#initialize(hash = {}, &block) ⇒ Phase
Returns a new instance of Phase.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/infostrada/phase.rb', line 53 def initialize(hash = {}, &block) @id = hash['n_PhaseID'] @name = hash['c_Phase'] @level = hash['n_PhaseLevel'] @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 block.call(self) if block_given? self end |
Instance Attribute Details
#current ⇒ 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 current @current end |
#currents ⇒ 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 currents @currents end |
#end_date ⇒ 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 end_date @end_date end |
#has_table ⇒ 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 has_table @has_table 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 |
#level ⇒ 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 level @level 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
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_name @phase3_name end |
#short_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 short_name @short_name end |
#start_date ⇒ 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 start_date @start_date end |
#table ⇒ Object
Get the classification table for this phase.
18 19 20 |
# File 'lib/infostrada/phase.rb', line 18 def table @table end |
Class Method Details
.from_json(json = {}) ⇒ Object
Useful method to get a Phase object from a json serialized Phase object.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/infostrada/phase.rb', line 33 def self.from_json(json = {}) new do |phase| phase.id = json['id'] phase.name = json['name'] phase.level = json['level'] phase.short_name = json['short_name'] phase.phase1_id = json['phase1_id'] phase.phase1_name = json['phase1_name'] phase.phase2_id = json['phase2_id'] phase.phase2_name = json['phase2_name'] phase.phase3_id = json['phase3_id'] phase.phase3_name = json['phase3_name'] phase.has_table = json['has_table'] phase.current = json['current'] phase.currents = json['currents'] phase.start_date = Date.parse(json['start_date'].to_s) if json['start_date'] phase.end_date = Date.parse(json['end_date'].to_s) if json['end_date'] end end |
Instance Method Details
#has_table? ⇒ Boolean
85 86 87 |
# File 'lib/infostrada/phase.rb', line 85 def has_table? @has_table end |