Class: Sportradar::Api::Football::Situation

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/football/situation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clockObject

Returns the value of attribute clock.



5
6
7
# File 'lib/sportradar/api/football/situation.rb', line 5

def clock
  @clock
end

#downObject

Returns the value of attribute down.



5
6
7
# File 'lib/sportradar/api/football/situation.rb', line 5

def down
  @down
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/sportradar/api/football/situation.rb', line 5

def location
  @location
end

#possessionObject

Returns the value of attribute possession.



5
6
7
# File 'lib/sportradar/api/football/situation.rb', line 5

def possession
  @possession
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/football/situation.rb', line 5

def response
  @response
end

#team_idObject

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

#yfdObject

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

#distanceObject



25
26
27
# File 'lib/sportradar/api/football/situation.rb', line 25

def distance
  @yfd
end

#down_distanceObject



29
30
31
# File 'lib/sportradar/api/football/situation.rb', line 29

def down_distance
  [@down, distance].compact.join(' & ')
end

#spotObject



21
22
23
# File 'lib/sportradar/api/football/situation.rb', line 21

def spot
  [location&.alias, location&.yardline].compact.join(' ')
end