Class: Google::Scholar::AuthorEnumerator
- Inherits:
-
Object
- Object
- Google::Scholar::AuthorEnumerator
- Includes:
- Enumerable
- Defined in:
- lib/google/scholar/author_enumerator.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(scraper) ⇒ AuthorEnumerator
constructor
A new instance of AuthorEnumerator.
Constructor Details
#initialize(scraper) ⇒ AuthorEnumerator
Returns a new instance of AuthorEnumerator.
6 7 8 9 10 |
# File 'lib/google/scholar/author_enumerator.rb', line 6 def initialize(scraper) @scraper = scraper @documents = scraper.documents self end |
Instance Method Details
#each ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/google/scholar/author_enumerator.rb', line 11 def each current_document = @documents.first i = 1 while(current_document) current_document..each {|| yield()} if(@documents.length > i) current_document = @documents[i] else if(@scraper.has_more_pages?) @scraper.load_next_page @documents = @scraper.documents current_document = @documents[i] else current_document = nil end end i += 1 end end |