Class: AhlScraper::TeamGameListItem

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

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

Returns a new instance of TeamGameListItem.



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

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

Instance Method Details

#at_home?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ahl_scraper/resources/team_game_list_item.rb', line 59

def at_home?
  @at_home ||= @opts[:team_id] == home_team[:id]
end

#away_scoreObject



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

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

#away_teamObject



52
53
54
55
56
57
# File 'lib/ahl_scraper/resources/team_game_list_item.rb', line 52

def away_team
  @away_team ||= {
    id: @raw_data[:prop][:visiting_team_city][:teamLink].to_i,
    city: @raw_data[:row][:visiting_team_city],
  }
end

#dateObject



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

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

#game_center_urlObject



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

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

#game_idObject



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

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

#game_nameObject



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

def game_name
  @game_name ||= "#{away_team[:city]} @ #{home_team[:city]}"
end

#game_report_urlObject



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

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

#game_sheet_urlObject



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

def game_sheet_url
  @game_sheet_url ||= @raw_data[:prop][:game_sheet][:link]
end

#home_scoreObject



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

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

#home_teamObject



45
46
47
48
49
50
# File 'lib/ahl_scraper/resources/team_game_list_item.rb', line 45

def home_team
  @home_team ||= {
    id: @raw_data[:prop][:home_team_city][:teamLink].to_i,
    city: @raw_data[:row][:home_team_city],
  }
end

#statusObject



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

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