Class: E621::Search
- Inherits:
-
Object
- Object
- E621::Search
- Defined in:
- lib/search.rb
Instance Method Summary collapse
-
#each_post ⇒ Object
Return each post via a block and process them individually.
-
#initialize(query, page = 1) ⇒ Search
constructor
commands update/download.
- #next_page ⇒ Object
- #page ⇒ Object
- #page=(page) ⇒ Object
- #posts ⇒ Object
- #previous_page ⇒ Object
Constructor Details
Instance Method Details
#each_post ⇒ Object
Return each post via a block and process them individually. This could cause a race condition in the unlikely manner when the queue is empty and not being filled again, but the worker is still runnning.
41 42 43 44 45 46 47 48 49 |
# File 'lib/search.rb', line 41 def each_post fetch_all until !@worker.status do until @queue.empty? do post = @queue.pop yield post end end end |
#next_page ⇒ Object
31 32 33 |
# File 'lib/search.rb', line 31 def next_page @request[:page] += 1 end |
#page ⇒ Object
55 56 57 |
# File 'lib/search.rb', line 55 def page return @request[:page] end |
#page=(page) ⇒ Object
59 60 61 |
# File 'lib/search.rb', line 59 def page=(page) @request[:page] = page end |
#posts ⇒ Object
51 52 53 |
# File 'lib/search.rb', line 51 def posts fetch end |
#previous_page ⇒ Object
35 36 37 |
# File 'lib/search.rb', line 35 def previous_page @request[:page] -= 1 end |