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
16 17 18 19 20 |
# File 'lib/mas/paginateable.rb', line 16 def first_record return 1 if current_page == 1 ((current_page - 1) * page_size) + 1 end |
#last_record ⇒ Object
22 23 24 25 26 |
# File 'lib/mas/paginateable.rb', line 22 def last_record last = current_page * page_size last > total_records ? total_records : last end |
#page_size ⇒ Object Also known as: limit_value
28 29 30 |
# File 'lib/mas/paginateable.rb', line 28 def page_size MAS::RadCore::PAGE_SIZE end |
#total_pages ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/mas/paginateable.rb', line 2 def total_pages if total_records < page_size 1 elsif (total_records % page_size).zero? total_records / page_size else (total_records / page_size) + 1 end end |
#total_records ⇒ Object
12 13 14 |
# File 'lib/mas/paginateable.rb', line 12 def total_records json['hits']['total'] end |