Sha256: c47891a8e66f0b9150684af31eef41bfead99ef17b5def0af05adcfd5d915490
Contents?: true
Size: 382 Bytes
Versions: 6
Compression:
Stored size: 382 Bytes
Contents
require 'facets/more/functor' require 'facets/core/symbol/chomp' class Proc # Build a hash out of a Proc. # # l = lambda { |s| # s.a = 1 # s.b = 2 # s.c = 3 # } # l.to_h #=> {:a=>1, :b=>2, :c=>3} # def to_h h = {} f = Functor.new{ |op, arg| h[op.chomp('=')] = arg } call( f ) h end end # TODO Write test for Proc#to_h.
Version data entries
6 entries across 6 versions & 1 rubygems