-
-
Save wycats/1493 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
require 'rubygems' | |
require 'json' | |
require 'pp' | |
if !ARGV[0] | |
puts "Usage: iphone.rb STATE" | |
exit | |
end | |
url = 'http://www.apple.com/retail/iphone/feeds/3g_us_inv.json' | |
json = Net::HTTP.get_response(URI.parse(url)).body | |
feed = JSON.parse(json) | |
feed['locations'][ARGV[0]].each do |location| | |
next if location['available']['black16'] == false | |
puts "#{location["name"]}, #{location["city"]}:" | |
puts "Black 16: #{location["available"]["black16"] ? "yes" : "no"}" | |
puts "White 16: #{location["available"]["white16"] ? "yes" : "no"}" | |
puts "Black 8: #{location["available"]["black8"] ? "yes" : "no"}" | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment