Class: CatAPI::Client
- Inherits:
-
Object
- Object
- CatAPI::Client
- Defined in:
- lib/cat_api/client.rb
Constant Summary collapse
- BASE_URL =
'http://thecatapi.com/api/'
Instance Method Summary collapse
- #get_images(options = {}) ⇒ Object
-
#initialize(defaults = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(defaults = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/cat_api/client.rb', line 9 def initialize(defaults={}) @defaults = defaults end |
Instance Method Details
#get_images(options = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cat_api/client.rb', line 13 def get_images(={}) = @defaults.merge() .delete_if {|k,v| v.nil? || ( v.kind_of?(Array) && v.empty? ) } response = get "#{ BASE_URL }images/get?format=xml&#{ URI.encode_www_form }" CatAPI::ImageSearch.new( Nokogiri::XML(response) ).results end |