Class: AhlScraper::Games::ScoringStatlinesService
- Inherits:
-
Object
- Object
- AhlScraper::Games::ScoringStatlinesService
- Defined in:
- lib/ahl_scraper/services/games/scoring_statlines_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(goal_data, skater_ids, opts = {}) ⇒ ScoringStatlinesService
constructor
A new instance of ScoringStatlinesService.
Constructor Details
#initialize(goal_data, skater_ids, opts = {}) ⇒ ScoringStatlinesService
Returns a new instance of ScoringStatlinesService.
6 7 8 9 10 |
# File 'lib/ahl_scraper/services/games/scoring_statlines_service.rb', line 6 def initialize(goal_data, skater_ids, opts = {}) @goal_data = goal_data @skater_ids = skater_ids @opts = opts end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ahl_scraper/services/games/scoring_statlines_service.rb', line 12 def call @goal_data.each do |goal| plus_player_count = goal[:plus_players].length minus_player_count = goal[:minus_players].length goalscorer_id = scoring_statlines[goal[:scoredBy][:id].to_s] ? goal[:scoredBy][:id].to_s : false # Make sure goal does not belong to goalie a1_id = goal[:assists][0]&.dig(:id) && scoring_statlines[goal[:assists][0]&.dig(:id).to_s] ? goal[:assists][0]&.dig(:id).to_s : false # Make sure assist exists and does not belong to goalie a2_id = goal[:assists][1]&.dig(:id) && scoring_statlines[goal[:assists][1]&.dig(:id).to_s] ? goal[:assists][1]&.dig(:id).to_s : false # Make sure assist exists and does not belong to goalie add_to_statline(goal, plus_player_count, minus_player_count, goalscorer_id, a1_id, a2_id) end scoring_statlines end |