Class: Hondana::Shelf
- Inherits:
-
Object
- Object
- Hondana::Shelf
- Defined in:
- lib/hondana.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #books ⇒ Object
- #description ⇒ Object
- #getdata ⇒ Object
-
#initialize(name) ⇒ Shelf
constructor
A new instance of Shelf.
- #url ⇒ Object
Constructor Details
#initialize(name) ⇒ Shelf
Returns a new instance of Shelf.
70 71 72 73 74 |
# File 'lib/hondana.rb', line 70 def initialize(name) @name = name @url = nil @description = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
75 76 77 |
# File 'lib/hondana.rb', line 75 def name @name end |
Instance Method Details
#books ⇒ Object
93 94 95 96 97 98 |
# File 'lib/hondana.rb', line 93 def books isbns = JSON.parse(Hondana.http_get("/books?shelf=#{@name}")) isbns.collect { |isbn| Book.new(isbn) } end |
#description ⇒ Object
88 89 90 91 |
# File 'lib/hondana.rb', line 88 def description getdata unless @description @description end |
#getdata ⇒ Object
77 78 79 80 81 |
# File 'lib/hondana.rb', line 77 def getdata data = JSON.parse(Hondana.http_get("/shelfinfo?shelf=#{CGI.escape(name)}")) @url = data['url'] @description = data['description'] end |
#url ⇒ Object
83 84 85 86 |
# File 'lib/hondana.rb', line 83 def url getdata unless @url @url end |