Class: ActionView::PartialIteration
- Defined in:
- actionview/lib/action_view/renderer/partial_renderer.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
The current iteration of the partial.
-
#size ⇒ Object
readonly
The number of iterations that will be done by the partial.
Instance Method Summary collapse
-
#first? ⇒ Boolean
Check if this is the first iteration of the partial.
-
#initialize(size) ⇒ PartialIteration
constructor
A new instance of PartialIteration.
-
#iterate! ⇒ Object
:nodoc:.
-
#last? ⇒ Boolean
Check if this is the last iteration of the partial.
Constructor Details
#initialize(size) ⇒ PartialIteration
Returns a new instance of PartialIteration.
14 15 16 17 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 14 def initialize(size) @size = size @index = 0 end |
Instance Attribute Details
#index ⇒ Object (readonly)
The current iteration of the partial.
12 13 14 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 12 def index @index end |
#size ⇒ Object (readonly)
The number of iterations that will be done by the partial.
9 10 11 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 9 def size @size end |
Instance Method Details
#first? ⇒ Boolean
Check if this is the first iteration of the partial.
20 21 22 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 20 def first? index == 0 end |
#iterate! ⇒ Object
:nodoc:
29 30 31 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 29 def iterate! # :nodoc: @index += 1 end |
#last? ⇒ Boolean
Check if this is the last iteration of the partial.
25 26 27 |
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 25 def last? index == size - 1 end |