Class: Tanker::Pagination::Kaminari

Inherits:
Array
  • Object
show all
Includes:
Kaminari::ConfigurationMethods::ClassMethods, Kaminari::PageScopeMethods
Defined in:
lib/tanker/pagination/kaminari.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_array, limit_val, offset_val, total_count) ⇒ Kaminari

Returns a new instance of Kaminari.



13
14
15
16
17
# File 'lib/tanker/pagination/kaminari.rb', line 13

def initialize(original_array, limit_val, offset_val, total_count)
  @limit_value = limit_val || default_per_page
  @offset_value, @total_count = offset_val, total_count
  super(original_array)
end

Instance Attribute Details

#limit_valueObject (readonly)

Returns the value of attribute limit_value.



11
12
13
# File 'lib/tanker/pagination/kaminari.rb', line 11

def limit_value
  @limit_value
end

#offset_valueObject (readonly)

Returns the value of attribute offset_value.



11
12
13
# File 'lib/tanker/pagination/kaminari.rb', line 11

def offset_value
  @offset_value
end

#total_countObject (readonly)

Returns the value of attribute total_count.



11
12
13
# File 'lib/tanker/pagination/kaminari.rb', line 11

def total_count
  @total_count
end

Class Method Details

.create(results, total_hits, options = {}) ⇒ Object



32
33
34
35
# File 'lib/tanker/pagination/kaminari.rb', line 32

def create(results, total_hits, options = {})
  instance = new(results, options[:per_page], options[:page]-1, total_hits)
  instance
end

Instance Method Details

#current_pageObject



27
28
29
# File 'lib/tanker/pagination/kaminari.rb', line 27

def current_page
  offset_value+1
end

#limit(num) ⇒ Object



23
24
25
# File 'lib/tanker/pagination/kaminari.rb', line 23

def limit(num)
  self
end

#page(num = 1) ⇒ Object



19
20
21
# File 'lib/tanker/pagination/kaminari.rb', line 19

def page(num = 1)
  self
end