Class: ActionView::PartialIteration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ PartialIteration

Returns a new instance of PartialIteration.



13
14
15
16
# File 'lib/action_view/renderer/collection_renderer.rb', line 13

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

Instance Attribute Details

#indexObject (readonly)

The current iteration of the partial.



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

def index
  @index
end

#sizeObject (readonly)

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



8
9
10
# File 'lib/action_view/renderer/collection_renderer.rb', line 8

def size
  @size
end

Instance Method Details

#first?Boolean

Check if this is the first iteration of the partial.

Returns:

  • (Boolean)


19
20
21
# File 'lib/action_view/renderer/collection_renderer.rb', line 19

def first?
  index == 0
end

#iterate!Object

:nodoc:



28
29
30
# File 'lib/action_view/renderer/collection_renderer.rb', line 28

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

#last?Boolean

Check if this is the last iteration of the partial.

Returns:

  • (Boolean)


24
25
26
# File 'lib/action_view/renderer/collection_renderer.rb', line 24

def last?
  index == size - 1
end