Class: Aladin::Books
- Inherits:
-
Array
- Object
- Array
- Aladin::Books
- Defined in:
- lib/aladin/books.rb
Class Attribute Summary collapse
-
.per_page ⇒ Object
Returns the value of attribute per_page.
-
.ttb_key ⇒ Object
Returns the value of attribute ttb_key.
Instance Attribute Summary collapse
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#error_msg ⇒ Object
Returns the value of attribute error_msg.
-
#page ⇒ Object
Returns the value of attribute page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#total ⇒ Object
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(hash) ⇒ Books
constructor
A new instance of Books.
Constructor Details
Class Attribute Details
.per_page ⇒ Object
Returns the value of attribute per_page.
5 6 7 |
# File 'lib/aladin/books.rb', line 5 def per_page @per_page end |
.ttb_key ⇒ Object
Returns the value of attribute ttb_key.
5 6 7 |
# File 'lib/aladin/books.rb', line 5 def ttb_key @ttb_key end |
Instance Attribute Details
#error_code ⇒ Object
Returns the value of attribute error_code.
48 49 50 |
# File 'lib/aladin/books.rb', line 48 def error_code @error_code end |
#error_msg ⇒ Object
Returns the value of attribute error_msg.
48 49 50 |
# File 'lib/aladin/books.rb', line 48 def error_msg @error_msg end |
#page ⇒ Object
Returns the value of attribute page.
48 49 50 |
# File 'lib/aladin/books.rb', line 48 def page @page end |
#per_page ⇒ Object
Returns the value of attribute per_page.
48 49 50 |
# File 'lib/aladin/books.rb', line 48 def per_page @per_page end |
#total ⇒ Object
Returns the value of attribute total.
48 49 50 |
# File 'lib/aladin/books.rb', line 48 def total @total end |
Class Method Details
.configure {|_self| ... } ⇒ Object
6 7 8 |
# File 'lib/aladin/books.rb', line 6 def configure yield self end |
.search(query, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/aladin/books.rb', line 10 def search(query, ={}) set_query(query, ) res = Net::HTTP.get_response(uri) if res.is_a?(Net::HTTPSuccess) body = res.body.gsub(/;?/, "") hash = JSON.parse(body) rescue JSON.parse(body.gsub("'", '"')) Books.new(hash) end end |
Instance Method Details
#error? ⇒ Boolean
60 61 62 |
# File 'lib/aladin/books.rb', line 60 def error? @error_code.present? end |