File: //usr/local/rvm/gems/ruby-2.6.8/doc/actionview-6.1.4.1/ri/ActionView/Helpers/TextHelper/cycle-i.ri
U:RDoc::AnyMethod[iI"
cycle:ETI"*ActionView::Helpers::TextHelper#cycle;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"NCreates a Cycle object whose _to_s_ method cycles through elements of an ;TI"Oarray every time it is called. This can be used for example, to alternate ;TI"Qclasses for table rows. You can use named cycles to allow nesting in loops. ;TI"RPassing a Hash as the last parameter with a <tt>:name</tt> key will create a ;TI"Hnamed cycle. The default name for a cycle without a +:name+ key is ;TI"O<tt>"default"</tt>. You can manually reset a cycle by calling reset_cycle ;TI"Qand passing the name of the cycle. The current cycle string can be obtained ;TI",anytime using the current_cycle method.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I": # Alternate CSS classes for even and odd numbers...
;TI" @items = [1,2,3,4]
;TI" <table>
;TI"" <% @items.each do |item| %>
;TI"2 <tr class="<%= cycle("odd", "even") -%>">
;TI" <td><%= item %></td>
;TI" </tr>
;TI" <% end %>
;TI" </table>
;TI"
;TI"O # Cycle CSS classes for rows, and text colors for values within each row
;TI"H @items = x = [{first: 'Robert', middle: 'Daniel', last: 'James'},
;TI"W {first: 'Emily', middle: 'Shannon', maiden: 'Pike', last: 'Hicks'},
;TI"A {first: 'June', middle: 'Dae', last: 'Jones'}]
;TI"" <% @items.each do |item| %>
;TI"E <tr class="<%= cycle("odd", "even", name: "row_class") -%>">
;TI" <td>
;TI". <% item.values.each do |value| %>
;TI"3 <%# Create a named cycle "colors" %>
;TI"Y <span style="color:<%= cycle("red", "green", "blue", name: "colors") -%>">
;TI" <%= value %>
;TI" </span>
;TI" <% end %>
;TI"( <% reset_cycle("colors") %>
;TI" </td>
;TI"
</tr>
;TI"<% end %>;T:@format0:
@fileI"+lib/action_view/helpers/text_helper.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(first_value, *values);T@3FI"TextHelper;TcRDoc::NormalModule00