class CatAPI::Client

Constants

BASE_URL

Attributes

categories[R]

Public Class Methods

new(defaults={}) click to toggle source
# File lib/cat_api/client.rb, line 11
def initialize(defaults={})
  @defaults = defaults
  response = get "#{ BASE_URL }categories/list"
  @categories = CatAPI::Categories.new( Nokogiri::XML(response) ).results
end

Public Instance Methods

get_images(options={}) click to toggle source
# File lib/cat_api/client.rb, line 17
def get_images(options={})
  options = @defaults.merge(options)
  options.delete_if {|k,v| v.nil? || ( v.kind_of?(Array) && v.empty? ) }
  response = get "#{ BASE_URL }images/get?format=xml&#{ URI.encode_www_form options }"
  CatAPI::ImageSearch.new( Nokogiri::XML(response) ).results
end

Private Instance Methods

get(url) click to toggle source
# File lib/cat_api/client.rb, line 26
def get(url)
  RestClient.get url
end