Class: Boxcab::ActionView::Helpers::BoxcabViewListIterator
- Inherits:
-
Object
- Object
- Boxcab::ActionView::Helpers::BoxcabViewListIterator
- Defined in:
- lib/boxcab/action_view/helpers.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #change(index) ⇒ Object
- #every?(n) ⇒ Boolean
- #first? ⇒ Boolean
-
#initialize(size = 0, index = 0) ⇒ BoxcabViewListIterator
constructor
A new instance of BoxcabViewListIterator.
- #last? ⇒ Boolean
Constructor Details
#initialize(size = 0, index = 0) ⇒ BoxcabViewListIterator
Returns a new instance of BoxcabViewListIterator.
95 96 97 |
# File 'lib/boxcab/action_view/helpers.rb', line 95 def initialize(size = 0, index = 0) @size, @index = size, index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
93 94 95 |
# File 'lib/boxcab/action_view/helpers.rb', line 93 def index @index end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
93 94 95 |
# File 'lib/boxcab/action_view/helpers.rb', line 93 def size @size end |
Instance Method Details
#change(index) ⇒ Object
111 112 113 114 |
# File 'lib/boxcab/action_view/helpers.rb', line 111 def change(index) @index = index self end |
#every?(n) ⇒ Boolean
107 108 109 |
# File 'lib/boxcab/action_view/helpers.rb', line 107 def every?(n) !first? && !last? && ((@index + 1) % n) == 0 end |
#first? ⇒ Boolean
99 100 101 |
# File 'lib/boxcab/action_view/helpers.rb', line 99 def first? @index == 0 end |
#last? ⇒ Boolean
103 104 105 |
# File 'lib/boxcab/action_view/helpers.rb', line 103 def last? @index == @size - 1 end |