123456789_123456789_123456789_123456789_123456789_

Class: ActionView::PartialIteration

Relationships & Source Files
Inherits: Object
Defined in: actionview/lib/action_view/renderer/collection_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/collection_renderer.rb', line 13

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/collection_renderer.rb', line 19

def first?
  index == 0
end

#index (readonly)

The current iteration of the partial.

[ GitHub ]

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

attr_reader :index

#last?Boolean (readonly)

Check if this is the last iteration of the partial.

[ GitHub ]

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

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/collection_renderer.rb', line 8

attr_reader :size