Class: RestBooks::Client
- Inherits:
-
Object
- Object
- RestBooks::Client
- Defined in:
- lib/restbooks.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#authors ⇒ Object
Use this object to acess authors resource.
-
#books ⇒ Object
Use this object to acess books resource.
-
#categories ⇒ Object
Use this object to acess categories resource.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#lists ⇒ Object
Use this object to acess lists resource.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/restbooks.rb', line 48 def initialize( ={} ) # Set host host = .has_key?( :host ) ? .delete(:host) : 'http://feedbooks.com' # Set user-agent @user_agent = .has_key?( :user_agent ) ? .delete( :user_agent ) : "RestBooks 0.1" # Set service URI @uri = URI.parse( host ) # Set authentification if .has_key?( :user ) && .has_key?( :password ) @uri.user = .delete( :user ) @uri.password = Digest::MD5.hexdigest( .delete( :password ) ) end # Set logger output RestClient.log = .delete( :log ) if .has_key?( :log ) # Init services @books = false @authors = false @lists = false @categories = false end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
46 47 48 |
# File 'lib/restbooks.rb', line 46 def uri @uri end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
46 47 48 |
# File 'lib/restbooks.rb', line 46 def user_agent @user_agent end |
Instance Method Details
#authors ⇒ Object
Use this object to acess authors resource
81 82 83 84 |
# File 'lib/restbooks.rb', line 81 def @authors = Authors.new( self ) if !@authors return @authors end |
#books ⇒ Object
Use this object to acess books resource
75 76 77 78 |
# File 'lib/restbooks.rb', line 75 def books @books = Books.new( self ) if !@books return @books end |
#categories ⇒ Object
Use this object to acess categories resource
93 94 95 96 |
# File 'lib/restbooks.rb', line 93 def categories @categories = Categories.new( self ) if !@categories return @categories end |
#lists ⇒ Object
Use this object to acess lists resource
87 88 89 90 |
# File 'lib/restbooks.rb', line 87 def lists @lists = Lists.new( self ) if !@lists return @lists end |