Created
October 5, 2018 19:11
-
-
Save apgordon/67ea5fc966732f7df7e4baf60a18d946 to your computer and use it in GitHub Desktop.
yesterday's nhl scores and today's games
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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