Class: Telm::Core::Query::Result
- Inherits:
-
Struct
- Object
- Struct
- Telm::Core::Query::Result
- Defined in:
- lib/telm/core/query.rb
Overview
rubocop:disable Lint/StructNewOverride -- :sort here is the sort column name; Struct#sort is never used on Result
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#page ⇒ Object
Returns the value of attribute page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#records ⇒ Object
Returns the value of attribute records.
-
#sort ⇒ Object
Returns the value of attribute sort.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #first_row ⇒ Object
- #last_row ⇒ Object
- #offset ⇒ Object
-
#pages ⇒ Object
rubocop:enable Lint/StructNewOverride.
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def dir @dir end |
#page ⇒ Object
Returns the value of attribute page
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def page @page end |
#per_page ⇒ Object
Returns the value of attribute per_page
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def per_page @per_page end |
#records ⇒ Object
Returns the value of attribute records
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def records @records end |
#sort ⇒ Object
Returns the value of attribute sort
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def sort @sort end |
#total ⇒ Object
Returns the value of attribute total
17 18 19 |
# File 'lib/telm/core/query.rb', line 17 def total @total end |
Instance Method Details
#first_row ⇒ Object
27 28 29 |
# File 'lib/telm/core/query.rb', line 27 def first_row total.zero? ? 0 : offset + 1 end |
#last_row ⇒ Object
31 32 33 |
# File 'lib/telm/core/query.rb', line 31 def last_row offset + records.size end |
#offset ⇒ Object
23 24 25 |
# File 'lib/telm/core/query.rb', line 23 def offset (page - 1) * per_page end |
#pages ⇒ Object
rubocop:enable Lint/StructNewOverride
19 20 21 |
# File 'lib/telm/core/query.rb', line 19 def pages [(total / per_page.to_f).ceil, 1].max end |