Module: Paginateable
- Included in:
- SearchResult
- Defined in:
- lib/mas/paginateable.rb
Instance Method Summary collapse
- #first_record ⇒ Object
- #last_record ⇒ Object
- #page_size ⇒ Object (also: #limit_value)
- #total_pages ⇒ Object
- #total_records ⇒ Object
Instance Method Details
#first_record ⇒ Object
10 11 12 13 14 |
# File 'lib/mas/paginateable.rb', line 10 def first_record return 1 if current_page == 1 ((current_page - 1) * page_size) + 1 end |
#last_record ⇒ Object
16 17 18 19 20 |
# File 'lib/mas/paginateable.rb', line 16 def last_record last = current_page * page_size last > total_records ? total_records : last end |
#page_size ⇒ Object Also known as: limit_value
22 23 24 |
# File 'lib/mas/paginateable.rb', line 22 def page_size MAS::RadCore::PAGE_SIZE end |
#total_pages ⇒ Object
2 3 4 |
# File 'lib/mas/paginateable.rb', line 2 def total_pages (total_records / page_size) + 1 end |
#total_records ⇒ Object
6 7 8 |
# File 'lib/mas/paginateable.rb', line 6 def total_records json['hits']['total'] end |