Class: Kadmin::PagerDecorator

Inherits:
Object
  • Object
show all
Defined in:
app/decorators/kadmin/pager_decorator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pager) ⇒ PagerDecorator

Returns a new instance of PagerDecorator.



10
11
12
# File 'app/decorators/kadmin/pager_decorator.rb', line 10

def initialize(pager)
  @pager = pager
end

Instance Attribute Details

#pagerKadmin::Pager (readonly)

Returns underlying pager model.

Returns:



4
5
6
# File 'app/decorators/kadmin/pager_decorator.rb', line 4

def pager
  @pager
end

Instance Method Details

#displayed_itemsInteger

Returns the current number of items displayed for this page.

Returns:

  • (Integer)

    the current number of items displayed for this page



15
16
17
# File 'app/decorators/kadmin/pager_decorator.rb', line 15

def displayed_items
  return page_end - offset
end

#next_page_offsetObject



29
30
31
# File 'app/decorators/kadmin/pager_decorator.rb', line 29

def next_page_offset
  return @pager.offset_at(current_page + 1)
end

#page_endInteger

Returns the index number of the last item for this page.

Returns:

  • (Integer)

    the index number of the last item for this page



20
21
22
# File 'app/decorators/kadmin/pager_decorator.rb', line 20

def page_end
  return [next_page_offset, total].min
end

#page_startInteger

Returns the index number of the start item for this page.

Returns:

  • (Integer)

    the index number of the start item for this page



25
26
27
# File 'app/decorators/kadmin/pager_decorator.rb', line 25

def page_start
  return offset + 1
end