Sha256: 021c23c96c94908c0699e6a6f0a6e68f5df8602c60945d93f351bfcbfec15b34
Contents?: true
Size: 727 Bytes
Versions: 2
Compression:
Stored size: 727 Bytes
Contents
module Rupture module Map def map? true end def associate(*kvs) into(kvs.seq.partition(2)) end def assoc(*kvs) associate(*kvs) end def into(other) other.seq.reduce(as_map) do |map, (k,v)| map.put(k,v) end end def update(key, fn = nil, *args, &block) if fn assoc(key, fn.call(self[key], *args, &block)) else assoc(key, yield(self[key])) end end def update_each(keys, *args, &block) map = as_map keys.each do |key| update(key, *args, &block) end map end def destruct(*keys) vals = keys.seq.map(self) block_given? ? yield(*vals) : vals end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rupture-0.3.0 | lib/rupture/map.rb |
rupture-0.2.1 | lib/rupture/map.rb |