Class: NyaaSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/nyaa_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ NyaaSearch

Returns a new instance of NyaaSearch.



25
26
27
28
29
30
31
# File 'lib/nyaa_search.rb', line 25

def initialize(args={})
  self.filter = args[:filter] ||  Nyaa::Filter::NoFilter
  self.category = args[:category] || Nyaa::Category::AllCategories
  self.query = args[:query] || ""
  self.submitter = args[:submitter] || nil
  self.page = args[:page] || 1
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



23
24
25
# File 'lib/nyaa_search.rb', line 23

def category
  @category
end

#filterObject

Returns the value of attribute filter.



23
24
25
# File 'lib/nyaa_search.rb', line 23

def filter
  @filter
end

#pageObject

Returns the value of attribute page.



23
24
25
# File 'lib/nyaa_search.rb', line 23

def page
  @page
end

#queryObject

Returns the value of attribute query.



23
24
25
# File 'lib/nyaa_search.rb', line 23

def query
  @query
end

#submitterObject

Returns the value of attribute submitter.



23
24
25
# File 'lib/nyaa_search.rb', line 23

def submitter
  @submitter
end

Instance Method Details

#querystringObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/nyaa_search.rb', line 33

def querystring
  form = {
    "f" => self.filter,
    "c" => self.category,
    "q" => self.query,
    "p" => self.page,
    "u" => self.submitter,
  }
  URI.encode_www_form(form.compact)
end