class ImageSearcher::Client

Attributes

options[R]
result[R]

Public Instance Methods

Private Instance Methods

build_json_url() click to toggle source
# File lib/image_searcher/client.rb, line 21
def build_json_url
  base_uri = ImageSearcher::API::BASE_URI
  url = "#{base_uri}?q=#{options[:query]}"
  url += "&count=#{options[:count]}" if options[:count]
  url
end
filter_by_format() click to toggle source
# File lib/image_searcher/client.rb, line 28
def filter_by_format
  format = options[:format]
  if format.is_a?(Array)
    format.each do |f|
      @result = result.keep_if { |h| h['url'].match(/.#{f}/i) }
    end
  else
    @result = result.keep_if { |h| h["url"].match(/.#{format}/i) }
  end

  @result
end
raise_errors() click to toggle source
# File lib/image_searcher/client.rb, line 16
def raise_errors
  raise "Missing params" if options[:query].nil?
  raise "Missing query" if options[:query].empty?
end