class AhlScraper::GameDataFetcher

Constants

BROKEN_GAMES

Public Class Methods

new(game_id) click to toggle source
# File lib/ahl_scraper/fetchers/game_data_fetcher.rb, line 7
def initialize(game_id)
  @game_id = game_id
end

Public Instance Methods

call() click to toggle source
# 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

Private Instance Methods

fixed_game() click to toggle source
# File lib/ahl_scraper/fetchers/game_data_fetcher.rb, line 19
def fixed_game
  path = File.join(File.dirname(__FILE__), "../fixed_games/#{@game_id}.json")
  file = File.read(path)
  JSON.parse(file, symbolize_names: true)
end
url() click to toggle source
# File lib/ahl_scraper/fetchers/game_data_fetcher.rb, line 25
def url
  "http://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=gameSummary&game_id=#{@game_id}&key=50c2cd9b5e18e390&site_id=1&client_code=ahl&lang=en&league_id=&callback=json" # rubocop:disable Layout/LineLength
end