Class: DynamicScaffold::List::Pagination
- Inherits:
-
Object
- Object
- DynamicScaffold::List::Pagination
- Defined in:
- lib/dynamic_scaffold/list/pagination.rb
Instance Attribute Summary collapse
-
#end_buttons ⇒ Object
readonly
Returns the value of attribute end_buttons.
-
#gap_buttons ⇒ Object
readonly
Returns the value of attribute gap_buttons.
-
#highlight_current ⇒ Object
readonly
Returns the value of attribute highlight_current.
-
#kaminari_options ⇒ Object
readonly
Returns the value of attribute kaminari_options.
-
#neighbor_buttons ⇒ Object
readonly
Returns the value of attribute neighbor_buttons.
-
#param_name ⇒ Object
readonly
Returns the value of attribute param_name.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(options) ⇒ Pagination
constructor
A new instance of Pagination.
- #page_class(page, _records) ⇒ Object
- #page_number(page, records) ⇒ Object
Constructor Details
#initialize(options) ⇒ Pagination
Returns a new instance of Pagination.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 16 def initialize() = { per_page: 25, window: 0, # kaminari options outer_window: 0, # kaminari options left: 0, # kaminari options right: 0, # kaminari options param_name: :page, # kaminari options total_count: true, # Whether to display total count on active page like `2 / 102` end_buttons: true, # Whether to display buttons to the first and last page. neighbor_buttons: true, # Whether to display buttons to the next and prev page. gap_buttons: false, # Whether to display gap buttons. highlight_current: false # Whether to highlight the current page. }.merge() @kaminari_options = .extract!(:window, :outer_window, :left, :right, :param_name) @param_name = @kaminari_options[:param_name] .each {|name, value| instance_variable_set("@#{name}", value) } end |
Instance Attribute Details
#end_buttons ⇒ Object (readonly)
Returns the value of attribute end_buttons.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def @end_buttons end |
#gap_buttons ⇒ Object (readonly)
Returns the value of attribute gap_buttons.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def @gap_buttons end |
#highlight_current ⇒ Object (readonly)
Returns the value of attribute highlight_current.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def highlight_current @highlight_current end |
#kaminari_options ⇒ Object (readonly)
Returns the value of attribute kaminari_options.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def @kaminari_options end |
#neighbor_buttons ⇒ Object (readonly)
Returns the value of attribute neighbor_buttons.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def @neighbor_buttons end |
#param_name ⇒ Object (readonly)
Returns the value of attribute param_name.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def param_name @param_name end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def per_page @per_page end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
6 7 8 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 6 def total_count @total_count end |
Instance Method Details
#page_class(page, _records) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 41 def page_class(page, _records) if page.inside_window? 'inner' elsif page.left_outer? 'left-outer' elsif page.right_outer? 'right-outer' end end |
#page_number(page, records) ⇒ Object
35 36 37 38 39 |
# File 'lib/dynamic_scaffold/list/pagination.rb', line 35 def page_number(page, records) return page unless total_count "#{page} / #{records.total_pages}" end |