Class: Archdown::Download
- Inherits:
-
Object
- Object
- Archdown::Download
- Defined in:
- lib/archdown/download.rb
Instance Attribute Summary collapse
-
#library_root ⇒ Object
readonly
Returns the value of attribute library_root.
-
#search_terms ⇒ Object
readonly
Returns the value of attribute search_terms.
Instance Method Summary collapse
- #go!(&each_book) ⇒ Object
-
#initialize(library_root, search_terms) ⇒ Download
constructor
A new instance of Download.
Constructor Details
Instance Attribute Details
#library_root ⇒ Object (readonly)
Returns the value of attribute library_root.
9 10 11 |
# File 'lib/archdown/download.rb', line 9 def library_root @library_root end |
#search_terms ⇒ Object (readonly)
Returns the value of attribute search_terms.
9 10 11 |
# File 'lib/archdown/download.rb', line 9 def search_terms @search_terms end |
Instance Method Details
#go!(&each_book) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/archdown/download.rb', line 17 def go!(&each_book) page = 1 loop do books = ::Retriable.retriable :on => Faraday::Error::TimeoutError do terms = @search_terms.merge(:page => page) begin @client.search(terms) rescue e $stderr.puts "Search Terms: #{JSON.pretty_generate(terms)}" raise end end break if books.empty? books.each do |book| Librarian.new(@library, book).store_book(&each_book) end page += 1 end end |