Class: Sportradar::Api::Football::StatPack
- Defined in:
- lib/sportradar/api/football/stat_pack.rb
Direct Known Subclasses
Defense, ExtraPoints, FieldGoals, Fumbles, IntReturns, KickReturns, Kickoffs, MiscReturns, Passing, Penalties, PuntReturns, Punts, Receiving, Rushing
Defined Under Namespace
Classes: Defense, ExtraPoints, FieldGoals, Fumbles, IntReturns, KickReturns, Kickoffs, MiscReturns, Passing, Penalties, PuntReturns, Punts, Receiving, Rushing
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#player ⇒ Object
Returns the value of attribute player.
-
#players ⇒ Object
Returns the value of attribute players.
-
#position ⇒ Object
Returns the value of attribute position.
-
#response ⇒ Object
Returns the value of attribute response.
-
#yards ⇒ Object
Returns the value of attribute yards.
Instance Method Summary collapse
- #for_player(id) ⇒ Object
-
#initialize(data) ⇒ StatPack
constructor
A new instance of StatPack.
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) ⇒ StatPack
Returns a new instance of StatPack.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 7 def initialize(data) if data['name'] @response = data @player = Sportradar::Api::Football::Nfl::Player.new(data) # need to handle ncaa/nfl, although it may not matter else @response = data['team'] || data['totals'] || data['kicks'] @players = parse_into_array(selector: data["players"], klass: self.class) if data["players"] end set_stats end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def name @name end |
#player ⇒ Object
Returns the value of attribute player.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def player @player end |
#players ⇒ Object
Returns the value of attribute players.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def players @players end |
#position ⇒ Object
Returns the value of attribute position.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def position @position end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def response @response end |
#yards ⇒ Object
Returns the value of attribute yards.
5 6 7 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 5 def yards @yards end |
Instance Method Details
#for_player(id) ⇒ Object
18 19 20 |
# File 'lib/sportradar/api/football/stat_pack.rb', line 18 def for_player(id) @players && @players.detect { |stat| stat.player.id == id } end |