class AhlScraper::SeasonTypeFetcher
Public Class Methods
new(season_id)
click to toggle source
# File lib/ahl_scraper/fetchers/season_type_fetcher.rb, line 5 def initialize(season_id) @season_id = season_id end
Public Instance Methods
call()
click to toggle source
# File lib/ahl_scraper/fetchers/season_type_fetcher.rb, line 9 def call season = JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true) .dig(:seasons) &.find { |s| s[:id].to_i == @season_id.to_i } return nil unless season case season[:name] when /Regular/ :regular when /All-Star/ :all_star when /Playoffs/ :playoffs when /Exhibition/ :exhibition end end
Private Instance Methods
url()
click to toggle source
# File lib/ahl_scraper/fetchers/season_type_fetcher.rb, line 29 def url "https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=bootstrap&season=latest&pageName=schedule&key=50c2cd9b5e18e390&client_code=ahl&site_id=1&league_id=&league_code=&lang=en&callback=json" end