Class: ActionView::Helpers::TextHelper::Cycle
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionview/lib/action_view/helpers/text_helper.rb |
Class Method Summary
- .new(first_value, *values) ⇒ Cycle constructor
Instance Attribute Summary
- #values readonly
Instance Method Summary
- #current_value
- #reset
- #to_s
- #next_index private
- #previous_index private
- #step_index(n) private
Constructor Details
.new(first_value, *values) ⇒ Cycle
Instance Attribute Details
#values (readonly)
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 483
attr_reader :values
Instance Method Details
#current_value
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 494
def current_value @values[previous_index].to_s end
#next_index (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 505
def next_index step_index(1) end
#previous_index (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 509
def previous_index step_index(-1) end
#reset
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 490
def reset @index = 0 end
#step_index(n) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 513
def step_index(n) (@index + n) % @values.size end
#to_s
[ GitHub ]# File 'actionview/lib/action_view/helpers/text_helper.rb', line 498
def to_s value = @values[@index].to_s @index = next_index value end