Class: E621::Search
- Inherits:
-
Object
- Object
- E621::Search
- Defined in:
- lib/search.rb
Instance Method Summary collapse
- #each_post ⇒ Object
-
#initialize(query) ⇒ Search
constructor
commands update/download.
- #next! ⇒ Object
- #page ⇒ Object
- #page=(page) ⇒ Object
- #previous! ⇒ Object
- #to_json(a = nil, b = nil) ⇒ Object
Constructor Details
#initialize(query) ⇒ Search
commands update/download
26 27 28 29 30 31 |
# File 'lib/search.rb', line 26 def initialize(query) @api,@mt = API.new("post"),Mutex.new @bad_tags = /(\s|^)(#{Config.blacklist.map{|x|Regexp.escape(x)}.join("|")})(\s|$)/ @request = {"limit"=>100,"page"=>1,"tags"=>query.join("+")} fetch end |
Instance Method Details
#each_post ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/search.rb', line 38 def each_post while @posts != Array.new do @posts.each do |post| yield post end next! end end |
#next! ⇒ Object
33 34 35 36 |
# File 'lib/search.rb', line 33 def next! @request["page"] += 1 fetch end |
#page ⇒ Object
47 48 49 |
# File 'lib/search.rb', line 47 def page return @request["page"] end |
#page=(page) ⇒ Object
51 52 53 54 |
# File 'lib/search.rb', line 51 def page=(page) @request["page"]=page fetch end |
#previous! ⇒ Object
56 57 58 59 |
# File 'lib/search.rb', line 56 def previous! @request["page"] -= 1 fetch end |