class Enumerable::LoopMeta
Attributes
__COUNTER__[R]
__EVEN__[R]
__FIRST__[R]
__INDEX__[R]
__INNER__[R]
__LAST__[R]
__ODD__[R]
__OUTER__[R]
__counter__[R]
__even__[R]
__first__[R]
__index__[R]
__inner__[R]
__last__[R]
__odd__[R]
__outer__[R]
counter[R]
even[R]
even?[R]
first[R]
first?[R]
index[R]
inner[R]
inner?[R]
last[R]
last?[R]
odd[R]
odd?[R]
outer[R]
outer?[R]
Public Class Methods
new( total )
click to toggle source
# File lib/html/template.rb, line 13 def initialize( total ) @total = total end
Public Instance Methods
index=(value)
click to toggle source
# File lib/html/template.rb, line 17 def index=(value) @index = value; @counter = @index+1 ## assume first item (index 0/counter 1) is odd - why? why not? ## 0 % 2 => 0 (odd) -- first ## 1 % 2 => 1 (even) -- second ## 2 % 2 => 0 ## 3 % 2 => 1 ## etc. @odd = (@index % 2) == 0 @even = !@odd if @index == 0 @first = true @inner = false @outer = true @last = (@total-1) == 0 elsif @index == (@total-1) @first = false @inner = false @outer = true @last = true else @first = false @inner = true @outer = false @last = false end end