Class: AhlScraper::GameDataFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ahl_scraper/fetchers/game_data_fetcher.rb

Constant Summary collapse

BROKEN_GAMES =
[1_018_774, 1_001_050, 1_020_527, 1_003_351].freeze

Instance Method Summary collapse

Constructor Details

#initialize(game_id) ⇒ GameDataFetcher

Returns a new instance of GameDataFetcher.



7
8
9
# File 'lib/ahl_scraper/fetchers/game_data_fetcher.rb', line 7

def initialize(game_id)
  @game_id = game_id
end

Instance Method Details

#callObject



11
12
13
14
15
# File 'lib/ahl_scraper/fetchers/game_data_fetcher.rb', line 11

def call
  return fixed_game if BROKEN_GAMES.include? @game_id

  JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
end