Class: Sportradar::Api::Football::StatsShim

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game) ⇒ StatsShim

Returns a new instance of StatsShim.



7
8
9
# File 'lib/sportradar/api/football/stats_shim.rb', line 7

def initialize(game)
  @game = game
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



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

def game
  @game
end

Instance Method Details

#dig(player_id, category, stat) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/sportradar/api/football/stats_shim.rb', line 11

def dig(player_id, category, stat)
  game.team_stats.each_value do |stats|
    player = stats.public_send(category).for_player(player_id)
    if player
      return player.send(stat)
    end
  end
  nil
end