Sha256: 6faa136b084479c169b69c006ecb160e2cefb5abb5d2ffb0c8cefcc42f80bb48

Contents?: true

Size: 595 Bytes

Versions: 3

Compression:

Stored size: 595 Bytes

Contents

require 'facets/enumerable/per'

module Enumerable

  # Returns an elemental object. This allows
  # you to map a method on to every element.
  #
  #   r = [1,2,3].every + 3  #=> [4,5,6]
  #
  def every
    per(:map)
  end

  # In place version of #every.
  #
  def every!
    raise NoMethodError unless respond_to?(:map!)
    per(:map!)
  end

  #def every
  #  Functor.new do |op,*args|
  #    map{ |a| a.send(op,*args) }
  #  end
  #end

  #def every!
  #  raise NoMethodError unless respond_to?(:map!)
  #  Functor.new do |op,*args|
  #    map!{ |a| a.send(op,*args) }
  #  end
  #end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/enumerable/every.rb
facets-2.8.3 lib/core/facets/enumerable/every.rb
facets-2.8.2 lib/core/facets/enumerable/every.rb