Class: FeedBooks::Book

Inherits:
FBobject show all
Defined in:
lib/ruby-feedbooks.rb

Overview

Book api object see feedbooks.com/api/books

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FBobject

#connection, connection, connection=, #connection=, from_xml

Constructor Details

#initialize(id = nil) ⇒ Book

Returns a new instance of Book.



184
185
186
# File 'lib/ruby-feedbooks.rb', line 184

def initialize(id=nil)
	@id=id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



183
184
185
# File 'lib/ruby-feedbooks.rb', line 183

def id
  @id
end

Class Method Details

.recent(limit = nil) ⇒ Object

get recent books (can be limited)



257
258
259
# File 'lib/ruby-feedbooks.rb', line 257

def self.recent(limit=nil)
	generic_iterate("/books/recent.xml",limit)
end

get recommedations based on user profile the user needs to be authenticatided see Connection



263
264
265
# File 'lib/ruby-feedbooks.rb', line 263

def self.recommended(limit=nil)
	generic_iterate("/recommendations.xml",limit)
end

.search(txt, limit = nil) ⇒ Object

Search in books catalog returns an Array



246
247
248
249
# File 'lib/ruby-feedbooks.rb', line 246

def self.search(txt,limit=nil)
	return [] if txt.strip.size==0
	generic_iterate("/books/search.xml?query=#{URI.escape(txt)}",limit)
end

.top(limit = nil) ⇒ Object

get top books (can be limited)



252
253
254
# File 'lib/ruby-feedbooks.rb', line 252

def self.top(limit=nil)
	generic_iterate("/books/top.xml",limit)
end

Instance Method Details

#authorsObject

authors is an array of Author



194
195
196
197
# File 'lib/ruby-feedbooks.rb', line 194

def authors 
	get_attr if @author==nil	
	@author
end

#coverObject



204
205
206
207
# File 'lib/ruby-feedbooks.rb', line 204

def cover
	get_attr if @title==nil	
	@cover
end

#dateObject



199
200
201
202
# File 'lib/ruby-feedbooks.rb', line 199

def date
	get_attr if @date==nil	
	@date
end

#descriptionObject



226
227
228
229
# File 'lib/ruby-feedbooks.rb', line 226

def description
	get_attr if @title==nil	
	@description
end

#file(format) ⇒ Object

give an url bases on asked format using the API results (other format may be available)



221
222
223
224
# File 'lib/ruby-feedbooks.rb', line 221

def file(format)
	get_attr if @files==nil	
	@files[format]
end

#languageObject



209
210
211
212
# File 'lib/ruby-feedbooks.rb', line 209

def language
	get_attr if @title==nil	
	@language
end

#lists(limit = nil) ⇒ Object

get an array of lists containing the book



268
269
270
# File 'lib/ruby-feedbooks.rb', line 268

def lists(limit=nil)
	FeedBooks::List.send('generic_iterate',"/book/#{@id}/lists.xml",limit)
end

#rightsObject



214
215
216
217
# File 'lib/ruby-feedbooks.rb', line 214

def rights
	get_attr if @title==nil	
	@rights
end

#similar(limit = nil) ⇒ Object

get similar books



241
242
243
# File 'lib/ruby-feedbooks.rb', line 241

def similar(limit=nil)
	self.class.generic_iterate("/book/#{@id}/similar.xml",limit)
end

#subjectsObject Also known as: types

subjects is an array of Type elements



233
234
235
236
# File 'lib/ruby-feedbooks.rb', line 233

def subjects
	get_attr if @title==nil
	@subject.collect{|s| FeedBooks::Type.new(s)}
end

#titleObject



188
189
190
191
# File 'lib/ruby-feedbooks.rb', line 188

def title
	get_attr if @title==nil	
	@title
end