Skip to content

Instantly share code, notes, and snippets.

@wycats
Forked from jackdempsey/iphone.rb
Created July 23, 2008 02:58
Show Gist options
  • Save wycats/1493 to your computer and use it in GitHub Desktop.
Save wycats/1493 to your computer and use it in GitHub Desktop.
#!/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