Class: Elasticord::Client::ArrayWithMetaData
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Elasticord::Client::ArrayWithMetaData
- Defined in:
- lib/elasticord/client/array_with_meta_data.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#total_results ⇒ Object
(also: #total_count)
Returns the value of attribute total_results.
Instance Method Summary collapse
- #from ⇒ Object
-
#initialize(page_default, per_page_default) ⇒ ArrayWithMetaData
constructor
A new instance of ArrayWithMetaData.
- #size ⇒ Object
- #total_pages ⇒ Object
Constructor Details
#initialize(page_default, per_page_default) ⇒ ArrayWithMetaData
Returns a new instance of ArrayWithMetaData.
6 7 8 9 10 11 12 13 14 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 6 def initialize(page_default, per_page_default) @internal_array = [] @per_page = per_page_default @current_page = page_default @total_results = 0 super(@internal_array) end |
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
4 5 6 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 4 def current_page @current_page end |
#per_page ⇒ Object
Returns the value of attribute per_page.
4 5 6 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 4 def per_page @per_page end |
#total_results ⇒ Object Also known as: total_count
Returns the value of attribute total_results.
4 5 6 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 4 def total_results @total_results end |
Instance Method Details
#from ⇒ Object
26 27 28 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 26 def from (current_page - 1) * size end |
#size ⇒ Object
22 23 24 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 22 def size per_page end |
#total_pages ⇒ Object
18 19 20 |
# File 'lib/elasticord/client/array_with_meta_data.rb', line 18 def total_pages (total_results / per_page.to_f).ceil end |