Class: AhlScraper::Games::ShootoutStatlinesService

Inherits:
Object
  • Object
show all
Defined in:
lib/ahl_scraper/services/games/shootout_statlines_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(shootout_data, team_id, skater_ids) ⇒ ShootoutStatlinesService

Returns a new instance of ShootoutStatlinesService.



6
7
8
9
10
# File 'lib/ahl_scraper/services/games/shootout_statlines_service.rb', line 6

def initialize(shootout_data, team_id, skater_ids)
  @shootout_data = shootout_data
  @team_id = team_id
  @skater_ids = skater_ids
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ahl_scraper/services/games/shootout_statlines_service.rb', line 12

def call
  return {} unless @shootout_data

  @shootout_data.each do |shootout_attempt|
    skater_id = shootout_attempt[:shooter][:id].to_s
    shootout_statlines[skater_id] ||= blank_statline

    shootout_statlines[skater_id][:attempts] += 1
    shootout_statlines[skater_id][:goals] += 1 if shootout_attempt[:isGoal]
    shootout_statlines[skater_id][:game_winners] += 1 if shootout_attempt[:isGameWinningGoal]
  end

  shootout_statlines
end