Skip to content

Instantly share code, notes, and snippets.

@apgordon
Created October 5, 2018 19:11
Show Gist options
  • Select an option

  • Save apgordon/67ea5fc966732f7df7e4baf60a18d946 to your computer and use it in GitHub Desktop.

Select an option

Save apgordon/67ea5fc966732f7df7e4baf60a18d946 to your computer and use it in GitHub Desktop.
yesterday's nhl scores and today's games
require 'httparty'
require 'chronic'
require 'pp'
@yesterday = Chronic.parse('yesterday').strftime("%Y-%m-%d")
@today = Chronic.parse('today').strftime("%Y-%m-%d")
@yesterday_schedule = JSON.parse(HTTParty.get("https://statsapi.web.nhl.com/api/v1/schedule?date=" + @yesterday).to_s)
@today_schedule = JSON.parse(HTTParty.get("https://statsapi.web.nhl.com/api/v1/schedule?date=" + @today).to_s)
puts "Yesterday's Scores:"
@yesterday_schedule["dates"][0]["games"].each {|x| puts "#{x["teams"]["away"]["team"]["name"]} - #{x["teams"]["away"]["score"]} | #{x["teams"]["home"]["team"]["name"]} - #{x["teams"]["home"]["score"]}" }
puts "\nToday's Games:"
@today_schedule["dates"][0]["games"].each {|x| puts "#{x["teams"]["away"]["team"]["name"]} vs. #{x["teams"]["home"]["team"]["name"]}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment