Sha256: 5911008988287201c49ff0d179027cc950df652eb7489243a6f9b47d196a6762

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module AhlScraper
  module Games
    class Overtime < Resource
      def number
        @number ||= @raw_data[:info][:id].to_i - 3
      end

      def name
        @name ||= "#{@raw_data[:info][:longName]}#{number}"
      end

      def length
        @length ||= ElapsedTimeHelper.new(length_in_seconds).to_min
      end

      def length_in_seconds
        @length_in_seconds ||=
          if scoring?
            PeriodTimeHelper.new(@raw_data[:goals][0][:time]).to_sec
          else
            @opts[:regular_season] ? 300 : 1200
          end
      end

      def scoring?
        @scoring ||= @raw_data[:goals].any?
      end

      def home_goals
        @home_goals ||= @raw_data[:stats][:homeGoals].to_i
      end

      def home_sog
        @home_sog ||= @raw_data[:stats][:homeShots].to_i
      end

      def away_goals
        @away_goals ||= @raw_data[:stats][:visitingGoals].to_i
      end

      def away_sog
        @away_sog ||= @raw_data[:stats][:visitingShots].to_i
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ahl_scraper-0.4.1 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.4.0 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.8 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.7 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.6 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.5 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.4 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.3 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.2 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.1 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.3.0 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.2.0 lib/ahl_scraper/resources/games/overtime.rb
ahl_scraper-0.1.1 lib/ahl_scraper/resources/games/overtime.rb