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 Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
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.
11 12 13 14 15 |
# 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 |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
7 8 9 |
# File 'lib/cat_api/client.rb', line 7 def categories @categories end |
Instance Method Details
#get_images(options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cat_api/client.rb', line 17 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 |