Class: RandomJpg::Loader::Flickr
- Inherits:
-
Object
- Object
- RandomJpg::Loader::Flickr
- Defined in:
- lib/random_jpg/loader/flickr.rb
Constant Summary collapse
- API_URL =
"http://api.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=66c61b93c4723c7c3a3c519728eac252&per_page=1&extras=url_m&format=json"
Instance Method Summary collapse
Instance Method Details
#feed(path) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/random_jpg/loader/flickr.rb', line 9 def feed(path) response = Net::HTTP.get URI(API_URL) hash = JSON.parse response[14..-2] image_data = Net::HTTP.get URI(hash["photos"]["photo"].first["url_m"]) File.open(path, "w") do |f| f.write image_data end end |