Class: Waistband::SearchResults::PaginatedArray

Inherits:
Array
  • Object
show all
Defined in:
lib/waistband/search_results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr, options) ⇒ PaginatedArray

Returns a new instance of PaginatedArray.



10
11
12
13
14
15
16
17
# File 'lib/waistband/search_results.rb', line 10

def initialize(arr, options)
  @current_page = (options[:current_page] || 1).to_i
  @total_count = (options[:total_count] || arr.length).to_i
  @per_page = (options[:per_page] || ::Waistband::SearchResults::DEFAULT_PAGE_SIZE).to_i
  @num_pages = @total_pages = (options[:num_pages] || (@total_count.to_f / @per_page).ceil)
  @limit_value = options[:limit]
  super(arr)
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def current_page
  @current_page
end

#limit_valueObject (readonly)

Returns the value of attribute limit_value.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def limit_value
  @limit_value
end

#num_pagesObject (readonly)

Returns the value of attribute num_pages.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def num_pages
  @num_pages
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def per_page
  @per_page
end

#total_countObject (readonly)

Returns the value of attribute total_count.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def total_count
  @total_count
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



8
9
10
# File 'lib/waistband/search_results.rb', line 8

def total_pages
  @total_pages
end