Class: Hondana::Shelf

Inherits:
Object
  • Object
show all
Defined in:
lib/hondana.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



75
76
77
# File 'lib/hondana.rb', line 75

def name
  @name
end

Instance Method Details

#booksObject



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

#descriptionObject



88
89
90
91
# File 'lib/hondana.rb', line 88

def description
  getdata unless @description
  @description
end

#getdataObject



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

#urlObject



83
84
85
86
# File 'lib/hondana.rb', line 83

def url
  getdata unless @url
  @url
end