Class: Sportradar::Api::Football::Nfl::LeagueDepthChart
- Includes:
- Enumerable
- Defined in:
- lib/sportradar/api/football/nfl/league_depth_chart.rb
Instance Attribute Summary collapse
-
#charts ⇒ Object
Returns the value of attribute charts.
-
#response ⇒ Object
Returns the value of attribute response.
-
#week_number ⇒ Object
Returns the value of attribute week_number.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(data, **opts) ⇒ LeagueDepthChart
constructor
A new instance of LeagueDepthChart.
-
#team(id = nil, abbrev: nil) ⇒ Object
id is preferred search, but we allow for team abbreviation too.
- #update(data, **opts) ⇒ 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, **opts) ⇒ LeagueDepthChart
Returns a new instance of LeagueDepthChart.
9 10 11 12 13 14 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 9 def initialize(data, **opts) @response = data @charts_hash = {} update(data, **opts) end |
Instance Attribute Details
#charts ⇒ Object
Returns the value of attribute charts.
7 8 9 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 7 def charts @charts end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 7 def response @response end |
#week_number ⇒ Object
Returns the value of attribute week_number.
7 8 9 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 7 def week_number @week_number end |
Instance Method Details
#each ⇒ Object
33 34 35 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 33 def each self.charts.each { |chart| yield chart } end |
#team(id = nil, abbrev: nil) ⇒ Object
id is preferred search, but we allow for team abbreviation too
29 30 31 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 29 def team(id = nil, abbrev: nil) charts.detect { |chart| chart.team_id == id || chart.abbrev == abbrev } end |
#update(data, **opts) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/sportradar/api/football/nfl/league_depth_chart.rb', line 16 def update(data, **opts) @week = data['week'] @week_number = data.dig('week', 'sequence') create_data(@charts_hash, data["teams"], klass: TeamDepthChart, api: opts[:api]) self end |