Sha256: 3b7e382c6b5c2673aa09e9d7b3e0369bdd7609c2323c1f1a2df0733a3bb0551e

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module AhlScraper
  module PlayoffBrackets
    class Series < Resource
      def id
        @id ||= @raw_data[:series_letter]
      end

      def name
        @name ||= @raw_data[:series_name]
      end

      def logo_url
        @logo_url ||= @raw_data[:series_logo]
      end

      def round
        @round ||= @raw_data[:round].to_i
      end

      def active?
        @active ||= @raw_data[:active] == "1"
      end

      def feeder_series1
        @feeder_series1 ||= @raw_data[:feeder_series1]
      end

      def feeder_series2
        @feeder_series2 ||= @raw_data[:feeder_series2]
      end

      def team1
        @team1 ||= @raw_data[:team1].to_i
      end

      def team2
        @team2 ||= @raw_data[:team2].to_i
      end

      def team1_wins
        @team1_wins ||= @raw_data[:team1_wins]
      end

      def team2_wins
        @team2_wins ||= @raw_data[:team2_wins]
      end

      def winning_team
        @winning_team ||= @raw_data[:winner].empty? ? nil : @raw_data[:winner].to_i
      end

      def ties
        @ties ||= @raw_data[:ties]
      end

      def home_team_id
        @home_team_id ||= first_game[:home_team].to_i
      end

      def games
        @games ||= @raw_data[:games].map { |game| Game.new(game) }
      end

      private

      def first_game
        @first_game ||= @raw_data[:games][0]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ahl_scraper-0.2.0 lib/ahl_scraper/resources/playoff_brackets/series.rb
ahl_scraper-0.1.1 lib/ahl_scraper/resources/playoff_brackets/series.rb