Module: Gemmy::Patches::EnumeratorPatch::InstanceMethods::Graph
- Defined in:
- lib/gemmy/patches/enumerator_patch.rb
Overview
Facets Similar to map by (array => hash) but values are not wrapped in arrays iteration return val is [key, val]
Instance Method Summary collapse
Instance Method Details
#graph(&yld) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gemmy/patches/enumerator_patch.rb', line 11 def graph(&yld) if yld h = {} each do |*kv| r = yld[*kv] case r when Hash nk, nv = *r.to_a[0] when Range nk, nv = r.first, r.last else nk, nv = *r end h[nk] = nv end h else Enumerator.new(self,:graph) end end |