Class: ActionView::PartialIteration

Inherits:
Object
  • Object
show all
Defined in:
actionview/lib/action_view/renderer/partial_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ PartialIteration

Returns a new instance of PartialIteration.


12
13
14
15
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 12

def initialize(size)
  @size  = size
  @index = 0
end

Instance Attribute Details

#indexObject (readonly)

The current iteration of the partial.


10
11
12
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 10

def index
  @index
end

#sizeObject (readonly)

The number of iterations that will be done by the partial.


7
8
9
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 7

def size
  @size
end

Instance Method Details

#first?Boolean

Check if this is the first iteration of the partial.

Returns:

  • (Boolean)

18
19
20
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 18

def first?
  index == 0
end

#iterate!Object

:nodoc:


27
28
29
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 27

def iterate! # :nodoc:
  @index += 1
end

#last?Boolean

Check if this is the last iteration of the partial.

Returns:

  • (Boolean)

23
24
25
# File 'actionview/lib/action_view/renderer/partial_renderer.rb', line 23

def last?
  index == size - 1
end