Class: ActionView::Helpers::TextHelper::Cycle

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/helpers/text_helper.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_value, *values) ⇒ Cycle

Returns a new instance of Cycle.



286
287
288
289
# File 'lib/action_view/helpers/text_helper.rb', line 286

def initialize(first_value, *values)
  @values = values.unshift(first_value)
  reset
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



284
285
286
# File 'lib/action_view/helpers/text_helper.rb', line 284

def values
  @values
end

Instance Method Details

#resetObject



291
292
293
# File 'lib/action_view/helpers/text_helper.rb', line 291

def reset
  @index = 0
end

#to_sObject



295
296
297
298
299
# File 'lib/action_view/helpers/text_helper.rb', line 295

def to_s
  value = @values[@index].to_s
  @index = (@index + 1) % @values.size
  return value
end