Sha256: a576d0936f4852e5b7e3d8462017d757f3ee7d3672620488192da6bfec57e609

Contents?: true

Size: 393 Bytes

Versions: 2

Compression:

Stored size: 393 Bytes

Contents

require "flickraw"
require "flickr_init"

module WordsToImage
  class Flickr
    def self.fetch(keyword)
      photo = flickr.photos.search(text: keyword, media: :photos, per_page: 1, sort: "interestingness-desc").first
      return if photo.nil?

      FlickRaw.url_q OpenStruct.new(photo.to_hash)
    rescue => e
      raise "problem connecting to flickr API: #{e.message}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
words_to_image-0.0.3 lib/words_to_image/flickr.rb
words_to_image-0.0.2 lib/words_to_image/flickr.rb