class AhlScraper::Games::PenaltyShotsService
Attributes
penalty_shot_data[R]
Public Class Methods
new(penalty_shot_data)
click to toggle source
# File lib/ahl_scraper/services/games/penalty_shots_service.rb, line 8 def initialize(penalty_shot_data) @penalty_shot_data = penalty_shot_data end
Public Instance Methods
call()
click to toggle source
# File lib/ahl_scraper/services/games/penalty_shots_service.rb, line 12 def call ordered_penalty_shots.map.with_index { |ps, i| PenaltyShot.new(ps, { number: i + 1 }) } end
Private Instance Methods
convert_time(game_time)
click to toggle source
# File lib/ahl_scraper/services/games/penalty_shots_service.rb, line 24 def convert_time(game_time) time = game_time.split(":") time[0].to_i * 60 + time[1].to_i end
ordered_penalty_shots()
click to toggle source
# File lib/ahl_scraper/services/games/penalty_shots_service.rb, line 18 def ordered_penalty_shots @ordered_penalty_shots ||= penalty_shot_data.sort do |a, b| [a[:period][:id].to_i, convert_time(a[:time])] <=> [b[:period][:id].to_i, convert_time(b[:time])] end end