Class: Waistband::SearchResults::PaginatedArray
- Inherits:
-
Array
- Object
- Array
- Waistband::SearchResults::PaginatedArray
- Defined in:
- lib/waistband/search_results.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#limit_value ⇒ Object
readonly
Returns the value of attribute limit_value.
-
#num_pages ⇒ Object
readonly
Returns the value of attribute num_pages.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(arr, options) ⇒ PaginatedArray
constructor
A new instance of PaginatedArray.
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, ) @current_page = ([:current_page] || 1).to_i @total_count = ([:total_count] || arr.length).to_i @per_page = ([:page_size] || [:per_page] || ::Waistband::SearchResults::DEFAULT_PAGE_SIZE).to_i @num_pages = @total_pages = ([:num_pages] || (@total_count.to_f / @per_page).ceil) @limit_value = [:limit] super(arr) end |
Instance Attribute Details
#current_page ⇒ Object (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_value ⇒ Object (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_pages ⇒ Object (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_page ⇒ Object (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_count ⇒ Object (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_pages ⇒ Object (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 |