Class: SmartPaginate::Paginate

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_page, per_page = nil) ⇒ Paginate



5
6
7
8
# File 'lib/smart_paginate/paginate.rb', line 5

def initialize(current_page, per_page = nil)
  @current_page = convert(current_page, 1)
  @per_page = convert(per_page, 20)
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



3
4
5
# File 'lib/smart_paginate/paginate.rb', line 3

def current_page
  @current_page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



3
4
5
# File 'lib/smart_paginate/paginate.rb', line 3

def per_page
  @per_page
end

Instance Method Details

#offsetObject



10
11
12
# File 'lib/smart_paginate/paginate.rb', line 10

def offset
  (current_page - 1) * per_page
end