Class: AhlScraper::GameListItem

Inherits:
Resource
  • Object
show all
Defined in:
lib/ahl_scraper/resources/game_list_item.rb

Instance Method Summary collapse

Methods inherited from Resource

#[], #each, #inspect, #keys, #to_json, #values

Constructor Details

#initialize(raw_data, opts = {}) ⇒ GameListItem

Returns a new instance of GameListItem.



5
6
7
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 5

def initialize(raw_data, opts = {})
  super(raw_data, opts)
end

Instance Method Details

#away_team_cityObject



25
26
27
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 25

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

#away_team_idObject



33
34
35
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 33

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

#away_team_scoreObject



29
30
31
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 29

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

#dateObject



37
38
39
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 37

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

#game_center_urlObject



53
54
55
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 53

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

#game_report_urlObject



45
46
47
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 45

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

#game_sheet_urlObject



49
50
51
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 49

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

#home_team_cityObject



13
14
15
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 13

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

#home_team_idObject



21
22
23
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 21

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

#home_team_scoreObject



17
18
19
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 17

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

#idObject



9
10
11
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 9

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

#statusObject



41
42
43
# File 'lib/ahl_scraper/resources/game_list_item.rb', line 41

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