Class: Fidelity::PaginationHelper::Pagination
- Inherits:
-
Object
- Object
- Fidelity::PaginationHelper::Pagination
- Defined in:
- app/fidelity/widgets/pagination/helpers/pagination_helper.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#options ⇒ Object
Returns the value of attribute options.
-
#page ⇒ Object
Returns the value of attribute page.
-
#range ⇒ Object
Returns the value of attribute range.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #back? ⇒ Boolean
- #each ⇒ Object
-
#initialize(options = {}) ⇒ Pagination
constructor
A new instance of Pagination.
- #next? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Pagination
Returns a new instance of Pagination.
11 12 13 14 15 16 17 18 19 20 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 11 def initialize ={} @options = @range = ([:range] || (1..10)).to_a @page = [:page] || 1 @size = [:size] || 7 @next = [:next] || true @offset_lenght = [0, @range.size - @size].max.to_i @offset_start = ((@range.size / 2) - (@offset_lenght / 2)).ceil.to_i @items = init_items(@offset_start, @offset_lenght) end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
10 11 12 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 10 def items @items end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 9 def @options end |
#page ⇒ Object
Returns the value of attribute page.
9 10 11 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 9 def page @page end |
#range ⇒ Object
Returns the value of attribute range.
9 10 11 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 9 def range @range end |
#size ⇒ Object
Returns the value of attribute size.
9 10 11 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 9 def size @size end |
Instance Method Details
#back? ⇒ Boolean
22 23 24 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 22 def back? range.first > 1 end |
#each ⇒ Object
30 31 32 33 34 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 30 def each @items.each do |item| yield item end end |
#next? ⇒ Boolean
26 27 28 |
# File 'app/fidelity/widgets/pagination/helpers/pagination_helper.rb', line 26 def next? @next end |