123456789_123456789_123456789_123456789_123456789_

Class: ActionView::PartialIteration

Relationships & Source Files
Inherits: Object
Defined in: actionview/lib/action_view/renderer/partial_renderer.rb

Class Method Summary

Instance Attribute Summary

  • #first? ⇒ Boolean readonly

    Check if this is the first iteration of the partial.

  • #index readonly

    The current iteration of the partial.

  • #last? ⇒ Boolean readonly

    Check if this is the last iteration of the partial.

  • #size readonly

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

Constructor Details

.new(size) ⇒ PartialIteration

[ GitHub ]

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

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

Instance Attribute Details

#first?Boolean (readonly)

Check if this is the first iteration of the partial.

[ GitHub ]

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

def first?
  index == 0
end

#index (readonly)

The current iteration of the partial.

[ GitHub ]

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

attr_reader :index

#last?Boolean (readonly)

Check if this is the last iteration of the partial.

[ GitHub ]

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

def last?
  index == size - 1
end

#size (readonly)

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

[ GitHub ]

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

attr_reader :size