Class: Sportradar::Api::Football::Situation
- Defined in:
- lib/sportradar/api/football/situation.rb
Instance Attribute Summary collapse
-
#clock ⇒ Object
Returns the value of attribute clock.
-
#down ⇒ Object
Returns the value of attribute down.
-
#location ⇒ Object
Returns the value of attribute location.
-
#possession ⇒ Object
Returns the value of attribute possession.
-
#response ⇒ Object
Returns the value of attribute response.
-
#team_id ⇒ Object
Returns the value of attribute team_id.
-
#yfd ⇒ Object
Returns the value of attribute yfd.
Instance Method Summary collapse
- #distance ⇒ Object
- #down_distance ⇒ Object
-
#initialize(data) ⇒ Situation
constructor
A new instance of Situation.
- #spot ⇒ Object
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data) ⇒ Situation
Returns a new instance of Situation.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sportradar/api/football/situation.rb', line 7 def initialize(data) @response = data @clock = data["clock"] @down = data["down"] @yfd = data["yfd"] @possession = OpenStruct.new(data["possession"]) if data["possession"] if data["location"] @location = OpenStruct.new(data["location"]) elsif data['side'] && data['yard_line'] @location = OpenStruct.new(alias: data['side'], yardline: data['yard_line']) end @team_id = possession&.id || data["team"] end |
Instance Attribute Details
#clock ⇒ Object
Returns the value of attribute clock.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def clock @clock end |
#down ⇒ Object
Returns the value of attribute down.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def down @down end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def location @location end |
#possession ⇒ Object
Returns the value of attribute possession.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def possession @possession end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def response @response end |
#team_id ⇒ Object
Returns the value of attribute team_id.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def team_id @team_id end |
#yfd ⇒ Object
Returns the value of attribute yfd.
5 6 7 |
# File 'lib/sportradar/api/football/situation.rb', line 5 def yfd @yfd end |
Instance Method Details
#distance ⇒ Object
25 26 27 |
# File 'lib/sportradar/api/football/situation.rb', line 25 def distance @yfd end |
#down_distance ⇒ Object
29 30 31 |
# File 'lib/sportradar/api/football/situation.rb', line 29 def down_distance [@down, distance].compact.join(' & ') end |
#spot ⇒ Object
21 22 23 |
# File 'lib/sportradar/api/football/situation.rb', line 21 def spot [location&.alias, location&.yardline].compact.join(' ') end |