Class: OKCupid::Paginator
- Inherits:
-
Object
- Object
- OKCupid::Paginator
- Defined in:
- lib/lonely_coder/search/options/paginator.rb
Overview
used to create the pagination part of a search url: low=1&count=10&ajax_load=1 where low is the start value count is the number of items per page
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
-
#initialize(options) ⇒ Paginator
constructor
A new instance of Paginator.
- #low ⇒ Object
- #next ⇒ Object
- #to_param ⇒ Object
Constructor Details
#initialize(options) ⇒ Paginator
Returns a new instance of Paginator.
9 10 11 12 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 9 def initialize() @per_page = [:per_page] @page = [:page] end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
7 8 9 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 7 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
7 8 9 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 7 def per_page @per_page end |
Instance Method Details
#low ⇒ Object
14 15 16 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 14 def low @low = ((@page - 1) * @per_page) + 1 end |
#next ⇒ Object
18 19 20 21 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 18 def next @page +=1 self end |
#to_param ⇒ Object
23 24 25 |
# File 'lib/lonely_coder/search/options/paginator.rb', line 23 def to_param "low=#{low}&count=#{@per_page}" end |