Class: RsPaginator::PageInfo
- Inherits:
-
Object
- Object
- RsPaginator::PageInfo
- Includes:
- ActionView::Context, ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
- Defined in:
- lib/rs_paginator/page_info.rb
Instance Method Summary collapse
-
#initialize(objects, context) ⇒ PageInfo
constructor
A new instance of PageInfo.
- #render ⇒ Object
Constructor Details
#initialize(objects, context) ⇒ PageInfo
Returns a new instance of PageInfo.
8 9 10 11 |
# File 'lib/rs_paginator/page_info.rb', line 8 def initialize(objects, context) @objects = objects @context = context end |
Instance Method Details
#render ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rs_paginator/page_info.rb', line 13 def render content_tag(:div, class: 'page_info') do if @objects.empty? @context.t('rs_paginator.page_info.empty') elsif @objects.total_pages == 1 && @objects.count == 1 @context.t('rs_paginator.page_info.one') elsif @objects.total_pages == 1 @context.t('rs_paginator.page_info.one_page', total: @objects.total) else from = @objects.per_page * (@objects.page - 1) + 1 to = from + @objects.count - 1 @context.t('rs_paginator.page_info.other', from: from, to: to, total: @objects.total) end end end |