Sha256: 09cd4b3fff22dd1ef724392c897622e6b2f575828cf6ddd07988f1fa6834367b

Contents?: true

Size: 489 Bytes

Versions: 15

Compression:

Stored size: 489 Bytes

Contents

# encoding: UTF-8

module Enumerable
  def slice_between(&b)
    Enumerator.new {|y|
      first = true
      buf = []
      prev = nil
      self.each {|elt|
        if first
          first = false
          buf << elt
          prev = elt
        else
          if b.call(prev, elt)
            y << buf
            buf = [elt]
          else
            buf << elt
          end
          prev = elt
        end
      }
      if !buf.empty?
        y << buf
      end
    }
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta9 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta8 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta7 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta6 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta5 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta4 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta3 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta2 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.beta1 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.alpha7 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.alpha6 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.alpha5 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.alpha4 lib/spontaneous/extensions/enumerable.rb
spontaneous-0.2.0.alpha3 lib/spontaneous/extensions/enumerable.rb