Sha256: d8479614269666749f6a16ce3bb89aafeb4570c54d9622c03619dba68ca05b62

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module AhlScraper
  class GameListItem < Resource
    def initialize(raw_data)
      @raw_data = raw_data
    end

    def id
      @id ||= @raw_data[:row][:game_id].to_i
    end

    def home_team_city
      @home_team_city ||= @raw_data[:row][:home_team_city]
    end

    def home_team_score
      @home_team_score ||= @raw_data[:row][:home_goal_count].to_i
    end

    def home_team_id
      @home_team_id ||= @raw_data[:prop][:home_team_city][:teamLink].to_i
    end

    def away_team_city
      @away_team_city ||= @raw_data[:row][:visiting_team_city]
    end

    def away_team_score
      @away_team_score ||= @raw_data[:row][:visiting_goal_count].to_i
    end

    def away_team_id
      @away_team_id ||= @raw_data[:prop][:visiting_team_city][:teamLink].to_i
    end

    def date
      @date ||= @raw_data[:row][:date_with_day]
    end

    def status
      @status ||= @raw_data[:row][:game_status]
    end

    def game_report_url
      @game_report_url ||= @raw_data[:prop][:game_report][:link]
    end

    def game_sheet_url
      @game_sheet_url ||= @raw_data[: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

2 entries across 2 versions & 1 rubygems

Version Path
ahl_scraper-0.2.0 lib/ahl_scraper/resources/game_list_item.rb
ahl_scraper-0.1.1 lib/ahl_scraper/resources/game_list_item.rb