Class: Sunspot::NullResult::PaginatedNullArray

Inherits:
Array
  • Object
show all
Defined in:
lib/sunspot/null_result.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, current_page: 1, per_page: 1) ⇒ PaginatedNullArray

Returns a new instance of PaginatedNullArray.



21
22
23
24
25
# File 'lib/sunspot/null_result.rb', line 21

def initialize(collection, current_page: 1, per_page: 1)
  super(collection)
  @current_page = current_page
  @per_page     = per_page
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



19
20
21
# File 'lib/sunspot/null_result.rb', line 19

def current_page
  @current_page
end

#per_pageObject (readonly) Also known as: limit_value

Returns the value of attribute per_page.



19
20
21
# File 'lib/sunspot/null_result.rb', line 19

def per_page
  @per_page
end

Instance Method Details

#first_page?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/sunspot/null_result.rb', line 44

def first_page?
  true
end

#last_page?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/sunspot/null_result.rb', line 48

def last_page?
  true
end

#next_pageObject



40
41
42
# File 'lib/sunspot/null_result.rb', line 40

def next_page
  (current_page+1) if total_pages > current_page
end

#offsetObject



56
57
58
# File 'lib/sunspot/null_result.rb', line 56

def offset
  0
end

#out_of_bounds?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/sunspot/null_result.rb', line 52

def out_of_bounds?
  false
end

#previous_pageObject



36
37
38
# File 'lib/sunspot/null_result.rb', line 36

def previous_page
  (current_page-1) if current_page > 1
end

#total_pagesObject Also known as: num_pages



30
31
32
# File 'lib/sunspot/null_result.rb', line 30

def total_pages
  [(size/per_page.to_f).ceil, 1].max
end