Class: Inquisitio::Results
- Inherits:
-
Array
- Object
- Array
- Inquisitio::Results
- Defined in:
- lib/inquisitio/results.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#results_per_page ⇒ Object
(also: #limit_value)
readonly
Returns the value of attribute results_per_page.
-
#time_ms ⇒ Object
readonly
Returns the value of attribute time_ms.
-
#total_count ⇒ Object
(also: #total_entries)
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(items, current_page, results_per_page, total_count, time_ms) ⇒ Results
constructor
A new instance of Results.
- #last_page? ⇒ Boolean
- #to_a ⇒ Object
- #total_pages ⇒ Object (also: #num_pages)
Constructor Details
#initialize(items, current_page, results_per_page, total_count, time_ms) ⇒ Results
Returns a new instance of Results.
3 4 5 6 |
# File 'lib/inquisitio/results.rb', line 3 def initialize(items, current_page, results_per_page, total_count, time_ms) super(items) @current_page, @results_per_page, @total_count, @time_ms = current_page, results_per_page, total_count, time_ms end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
8 9 10 |
# File 'lib/inquisitio/results.rb', line 8 def current_page @current_page end |
#results_per_page ⇒ Object (readonly) Also known as: limit_value
Returns the value of attribute results_per_page.
8 9 10 |
# File 'lib/inquisitio/results.rb', line 8 def results_per_page @results_per_page end |
#time_ms ⇒ Object (readonly)
Returns the value of attribute time_ms.
8 9 10 |
# File 'lib/inquisitio/results.rb', line 8 def time_ms @time_ms end |
#total_count ⇒ Object (readonly) Also known as: total_entries
Returns the value of attribute total_count.
8 9 10 |
# File 'lib/inquisitio/results.rb', line 8 def total_count @total_count end |
Instance Method Details
#last_page? ⇒ Boolean
17 18 19 |
# File 'lib/inquisitio/results.rb', line 17 def last_page? current_page == total_pages end |
#to_a ⇒ Object
21 22 23 |
# File 'lib/inquisitio/results.rb', line 21 def to_a self end |
#total_pages ⇒ Object Also known as: num_pages
12 13 14 |
# File 'lib/inquisitio/results.rb', line 12 def total_pages (total_count / results_per_page.to_f).ceil end |