Class: EbookLibrary::Gatherer
- Inherits:
-
Object
- Object
- EbookLibrary::Gatherer
- Defined in:
- lib/ebook_library/gatherer.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #gather ⇒ Object
-
#initialize(path = EbookLibrary.default_path) ⇒ Gatherer
constructor
A new instance of Gatherer.
Constructor Details
#initialize(path = EbookLibrary.default_path) ⇒ Gatherer
Returns a new instance of Gatherer.
11 12 13 14 |
# File 'lib/ebook_library/gatherer.rb', line 11 def initialize(path=EbookLibrary.default_path) @path = path if File.exist?(path) raise InvalidPath if @path.nil? end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/ebook_library/gatherer.rb', line 9 def path @path end |
Instance Method Details
#gather ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ebook_library/gatherer.rb', line 16 def gather results = gather_ebooks.map do |book_path| begin ebook = Ebook.new(book_path) ebook.to_hash rescue EbookLibrary::UnsupportedFormatError puts "skipping: " + book_path end end { books: results.compact } end |