Sha256: b68e4da9f4cee87afb97e7d3657c2ecf81884e4ef45468711e237815948a9279

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module AhlScraper
  class GameListItem < Resource
    def initialize(raw_data, opts = {})
      super(raw_data, opts)
    end

    def id
      @id ||= @raw_data&.dig(:row, :game_id).to_i
    end

    def home_team_city
      @home_team_city ||= @raw_data&.dig(:row, :home_team_city)
    end

    def home_team_score
      @home_team_score ||= @raw_data&.dig(:row, :home_goal_count).to_i
    end

    def home_team_id
      @home_team_id ||= @raw_data&.dig(:prop, :home_team_city, :teamLink).to_i
    end

    def away_team_city
      @away_team_city ||= @raw_data&.dig(:row, :visiting_team_city)
    end

    def away_team_score
      @away_team_score ||= @raw_data&.dig(:row, :visiting_goal_count).to_i
    end

    def away_team_id
      @away_team_id ||= @raw_data&.dig(:prop, :visiting_team_city, :teamLink).to_i
    end

    def date
      @date ||= @raw_data&.dig(:row, :date_with_day)
    end

    def status
      @status ||= @raw_data&.dig(:row, :game_status)&.match(/am|pm/) ? "Not Started" : @raw_data&.dig(:row, :game_status)
    end

    def game_report_url
      @game_report_url ||= @raw_data&.dig(:prop, :game_report, :link)
    end

    def game_sheet_url
      @game_sheet_url ||= @raw_data&.dig(:prop, :game_sheet, :link)
    end

    def game_center_url
      @game_center_url ||= "https://theahl.com/stats/game-center/#{id}"
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ahl_scraper-0.4.0 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.8 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.7 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.6 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.5 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.4 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.3 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.2 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.1 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.3.0 lib/ahl_scraper/resources/game_list_item.rb