module Polyfill::V2_3::Enumerable

Public Instance Methods

chunk_while() click to toggle source
# File lib/polyfill/v2_3/enumerable.rb, line 4
def chunk_while
  block = ::Proc.new

  ::Enumerator.new do |yielder|
    output = []
    each do |element, *rest|
      elements = rest.any? ? [element, *rest] : element

      if output.empty? || block.call(output.last, elements)
        output.push(elements)
      else
        yielder << output
        output = [elements]
      end
    end
    yielder << output unless output.empty?
  end
end
grep_v(pattern) click to toggle source
# File lib/polyfill/v2_3/enumerable.rb, line 23
def grep_v(pattern)
  output = to_a - grep(pattern)
  output.map!(&::Proc.new) if block_given?
  output
end
slice_before(*args) click to toggle source
Calls superclass method
# File lib/polyfill/v2_3/enumerable.rb, line 29
def slice_before(*args)
  if !args.empty? && block_given?
    raise ArgumentError, 'wrong number of arguments (given 1, expected 0)'
  end

  super
end