class BootstrapPager::PaginatableArray
Kind of Array that can paginate
Public Class Methods
new(original_array = [], options = {})
click to toggle source
Options¶ ↑
-
:limit
- limit -
:offset
- offset -
:total_count
-total_count
Calls superclass method
# File lib/bootstrap_pager/models/array_extension.rb, line 13 def initialize(original_array = [], options = {}) @_original_array, @_limit_value, @_offset_value, @_total_count, @_padding = original_array, (options[:limit] || default_per_page).to_i, options[:offset].to_i, options[:total_count], options[:padding].to_i if options[:limit] && options[:offset] extend BootstrapPager::PageScopeMethods end if options[:total_count] super original_array else super(original_array[@_offset_value, @_limit_value] || []) end end
Public Instance Methods
limit(num)
click to toggle source
returns another chunk of the original array
# File lib/bootstrap_pager/models/array_extension.rb, line 35 def limit(num) self.class.new @_original_array, :limit => num, :offset => @_offset_value, :total_count => @_total_count, :padding => @_padding end
offset(num)
click to toggle source
returns another chunk of the original array
# File lib/bootstrap_pager/models/array_extension.rb, line 45 def offset(num) self.class.new @_original_array, :limit => @_limit_value, :offset => num, :total_count => @_total_count, :padding => @_padding end
total_count()
click to toggle source
total item numbers of the original array
# File lib/bootstrap_pager/models/array_extension.rb, line 40 def total_count @_total_count || @_original_array.count end