class SmartPaginate::Paginate
Attributes
current_page[R]
per_page[R]
Public Class Methods
new(current_page, per_page = nil)
click to toggle source
# 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
Public Instance Methods
offset()
click to toggle source
# File lib/smart_paginate/paginate.rb, line 10 def offset (current_page - 1) * per_page end
Private Instance Methods
convert(value, default_value)
click to toggle source
# File lib/smart_paginate/paginate.rb, line 16 def convert(value, default_value) value = value.to_i value > 0 ? value : default_value end