Class: ActionView::PartialIteration

Inherits:
Object
  • Object
show all
Defined in:
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.



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

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

Instance Attribute Details

#indexObject (readonly)

The current iteration of the partial.



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

def index
  @index
end

#sizeObject (readonly)

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



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

def size
  @size
end

Instance Method Details

#first?Boolean

Check if this is the first iteration of the partial.

Returns:

  • (Boolean)


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

def first?
  index == 0
end

#iterate!Object

:nodoc:



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

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

#last?Boolean

Check if this is the last iteration of the partial.

Returns:

  • (Boolean)


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

def last?
  index == size - 1
end