Sha256: 0550b5a7927e0620169ddb9f84af3c378ccabdad6e1348b070f33c80517f4f61
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Option module Enumerable include ::Enumerable def do &block each &block self end def to_ary to_a end def flatten from_array to_ary.flatten end def juxt(*methods) map { |v| methods.map { |m| v.send(m) } } end def map_through(*methods) methods.reduce(self) { |acc, m| acc.map(&m) } end def map from_array super end alias_method :collect, :map alias_method :collect_concat, :map def flat_map(&block) map(&block).flatten end def detect from_value super end alias_method :find, :detect def select from_array super end alias_method :find_all, :select def grep(value) from_array super end def reject(*args, &block) from_array to_a.reject(*args, &block) end def reduce(*args, &block) if none? && (args.size < 1 || args.size < 2 && block.nil?) raise ValueOfNoneError end super end alias_method :inject, :reduce end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
optional-0.0.4 | lib/optional/option/enumerable.rb |