Class: FeedBooks::Author

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

Overview

Author object see feedbooks.com/api/authors

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) ⇒ Author

Returns a new instance of Author.



308
309
310
# File 'lib/ruby-feedbooks.rb', line 308

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



306
307
308
# File 'lib/ruby-feedbooks.rb', line 306

def id
  @id
end

Class Method Details

.from_h(h) ⇒ Object

:nodoc:



359
360
361
362
363
364
# File 'lib/ruby-feedbooks.rb', line 359

def self.from_h(h) #:nodoc:
	r=Author.new
	r.send('id=',h['id'])
	r.fullname=h['author']
	r
end

.recent(limit = nil) ⇒ Object

Recent authors



378
379
380
# File 'lib/ruby-feedbooks.rb', line 378

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

.search(txt, limit = nil) ⇒ Object

Search through author catalog



367
368
369
370
# File 'lib/ruby-feedbooks.rb', line 367

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

.top(limit = nil) ⇒ Object

Top authors (by download)



373
374
375
# File 'lib/ruby-feedbooks.rb', line 373

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

Instance Method Details

#biographyObject



354
355
356
357
# File 'lib/ruby-feedbooks.rb', line 354

def biography
	get_attr if @biography==nil	
	@biography
end

#birthObject



332
333
334
335
# File 'lib/ruby-feedbooks.rb', line 332

def birth
	get_attr if @birth==nil	
	@birth
end

#books(limit = nil) ⇒ Object

Array of books written by this author



383
384
385
# File 'lib/ruby-feedbooks.rb', line 383

def books(limit=nil)
	FeedBooks::Book.send('generic_iterate',"/author/#{@id}/books.xml",limit)
end

#books_countObject

Number of books written by this author



343
344
345
346
# File 'lib/ruby-feedbooks.rb', line 343

def books_count
	get_attr if @books==nil	
	@books
end

#deathObject



337
338
339
340
# File 'lib/ruby-feedbooks.rb', line 337

def death
	get_attr if @birth==nil	
	@death
end

#downloads_countObject

Count of downloaded books from author



349
350
351
352
# File 'lib/ruby-feedbooks.rb', line 349

def downloads_count
	get_attr if @downloads==nil	
	@downloads
end

#firstnameObject



327
328
329
330
# File 'lib/ruby-feedbooks.rb', line 327

def firstname
	get_attr if @firstname==nil	
	@firstname
end

#fullnameObject

virtual attribute fullname based on firstname and name



317
318
319
320
# File 'lib/ruby-feedbooks.rb', line 317

def fullname
	get_attr if @name==nil	
	@name+", "+@firstname
end

#fullname=(txt) ⇒ Object

:nodoc:



312
313
314
# File 'lib/ruby-feedbooks.rb', line 312

def fullname=(txt) #:nodoc:
	@name,@firstname=txt.split(",")
end

#nameObject



322
323
324
325
# File 'lib/ruby-feedbooks.rb', line 322

def name
	get_attr if @name==nil	
	@name
end

#recent_books(limit = nil) ⇒ Object

Array of recent books written by this author



393
394
395
# File 'lib/ruby-feedbooks.rb', line 393

def recent_books(limit=nil)
	FeedBooks::Book.send('generic_iterate',"/author/#{@id}/books/recent.xml",limit)
end

#top_books(limit = nil) ⇒ Object

Array of top books written by this author



388
389
390
# File 'lib/ruby-feedbooks.rb', line 388

def top_books(limit=nil)
	FeedBooks::Book.send('generic_iterate',"/author/#{@id}/books/top.xml",limit)
end