lib/ahl_scraper/resources/games/penalty.rb in ahl_scraper-0.1.1 vs lib/ahl_scraper/resources/games/penalty.rb in ahl_scraper-0.2.0

- old
+ new

@@ -1,16 +1,20 @@ # frozen_string_literal: true module AhlScraper module Games class Penalty < Resource + def id + @id ||= @raw_data.dig(:game_penalty_id)&.to_i + end + def number @number ||= @opts[:number] end def period - @period ||= @raw_data.dig(:period, :id).to_i + @period ||= @raw_data.dig(:period, :id)&.to_i end def time @time ||= @raw_data[:time] end @@ -68,15 +72,25 @@ def rule_number @rule_number ||= @raw_data[:rule_number] end def power_play? - @power_play ||= @raw_data[:isPowerPlay] + @raw_data[:isPowerPlay] end + def bench? + @raw_data[:isPowerPlay] + end + + def invalid? + [240_773].include? id + end + def penalty_type @penalty_type ||= case @raw_data[:description] + when /penalty shot/i + :penalty_shot when /double minor/i :double_minor when /major/i :major when /fighting/i