<commit_before>= array_floe

== Overview

This small extension to ruby's Array class simplifies the reasonably-common
need to specially handle "floe"--i.e., <b>f</b>irst, <b>l</b>ast, <b>o</b>dd, <b>e</b>ven--when
iterating through the elements of an array.  It's particularly handy for
generating CSS classes.

Full Rdoc is available at http://rubydoc.info/gems/array_floe

== Usage

The gem provides two additional iterators, Array#each_with_floe and
Array#each_with_index_floe, that provide a "floe" object for each element
in the array:

    ary.each_with_floe do |element, floe|
        if floe.first?
            puts "#{element} is the first element"
        end
        if floe.last?
            puts "#{element} is the last element"
        end
        if floe.odd?
            puts "#{element} is an odd-numbered element"
        end
        if floe.even?
            puts "#{element} is an even-numbered element"
        end
    end

    ary.each_with_index_floe do |element, i, floe|
        assert_equal(i == 0,        floe.first?)
        assert_equal(i == ary.last, floe.last?)
        assert_equal(i % 2 == 1,    float.odd?)
        assert_equal(i % 2 == 1,    float.even?)
    end

If no block is given, an enumerator is returned instead.

The "floe" object's <code>to_s</code> method returns a space-separated list
of "first", "last", "odd", and "even" as appropriate:

    [:a, :b, :c, :d].each_with_floe.collect{|element, floe| floe.to_s} #=> [ "first even", "odd", "even", "last odd" ]

<code>floe.to_s</code> is particularly useful to construct CSS classes when generating HTML.  For
example, this haml[http://haml-lang.com/] snippet:

    %table
    - [:a, :b, :c, :d].each_with_floe do |row, floe|
      %tr{:class => floe}
        %td= row

would yield this HTML snippet:

    <table>
        <tr class="first even">
            <td>a</td>
        </tr>
        <tr class="odd">
            <td>b</td>
        </tr>
        <tr class="even">
            <td>c</td><commit_msg>README typo fix<commit_after>= array_floe

== Overview

This small extension to ruby's Array class simplifies the reasonably-common
need to specially handle "floe"--i.e., <b>f</b>irst, <b>l</b>ast, <b>o</b>dd, <b>e</b>ven--when
iterating through the elements of an array.  It's particularly handy for
generating CSS classes.

Full Rdoc is available at http://rubydoc.info/gems/array_floe

== Usage

The gem provides two additional iterators, Array#each_with_floe and
Array#each_with_index_floe, that provide a "floe" object for each element
in the array:

    ary.each_with_floe do |element, floe|
        if floe.first?
            puts "#{element} is the first element"
        end
        if floe.last?
            puts "#{element} is the last element"
        end
        if floe.odd?
            puts "#{element} is an odd-numbered element"
        end
        if floe.even?
            puts "#{element} is an even-numbered element"
        end
    end

    ary.each_with_index_floe do |element, i, floe|
        assert_equal(i == 0,        floe.first?)
        assert_equal(i == ary.last, floe.last?)
        assert_equal(i % 2 == 1,    float.odd?)
        assert_equal(i % 2 == 0,    float.even?)
    end

If no block is given, an enumerator is returned instead.

The "floe" object's <code>to_s</code> method returns a space-separated list
of "first", "last", "odd", and "even" as appropriate:

    [:a, :b, :c, :d].each_with_floe.collect{|element, floe| floe.to_s} #=> [ "first even", "odd", "even", "last odd" ]

<code>floe.to_s</code> is particularly useful to construct CSS classes when generating HTML.  For
example, this haml[http://haml-lang.com/] snippet:

    %table
    - [:a, :b, :c, :d].each_with_floe do |row, floe|
      %tr{:class => floe}
        %td= row

would yield this HTML snippet:

    <table>
        <tr class="first even">
            <td>a</td>
        </tr>
        <tr class="odd">
            <td>b</td>
        </tr>
        <tr class="even">
            <td>c</td>
{'fraction_non_alphanumeric': 0.13136863136863136, 'fraction_numerical': 0.0024975024975024975, 'mean_word_length': 2.5162423178226514, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3246460', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1343, 'n_words': 419}