Sha256: f946a4305f2b61abc55921d7f292eca872d9295e238183c2c386858b656ccd8f

Contents?: true

Size: 490 Bytes

Versions: 22

Compression:

Stored size: 490 Bytes

Contents

require 'facet/enumerable/graph'

class Hash
  # As with Enumerable#graph but acts in place.
  def graph!( &blk )
    self.replace( graph( &blk ) )
  end
end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCHash < Test::Unit::TestCase

    def test_graph
      h  = {:a=>1,:b=>2,:c=>3}
      h.graph!{ |k,v| [v, v*v] }
      assert_equal( {1=>1, 2=>4, 3=>9}, h )
    end

  end

=end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
facets-1.0.3 packages/core/lib/facet/hash/graph.rb
facets-1.0.0 lib/facet/hash/graph.rb
facets-1.3.0 lib/facets/core/hash/graph.rb
facets-1.1.0 lib/facet/hash/graph.rb
facets-1.2.0 lib/facets/core/hash/graph.rb
facets-1.2.1 lib/facets/core/hash/graph.rb
facets-1.3.2 lib/facets/core/hash/graph.rb
facets-1.3.3 lib/facets/core/hash/graph.rb
facets-1.3.1 lib/facets/core/hash/graph.rb
facets-1.4.2 lib/facets/core/hash/graph.rb
facets-1.4.0 lib/facets/core/hash/graph.rb
facets-1.4.1 lib/facets/core/hash/graph.rb
facets-1.4.3 lib/facets/core/hash/graph.rb
facets-1.4.4 lib/facets/core/hash/graph.rb
facets-1.4.5 lib/facets/core/hash/graph.rb
facets-1.7.38 lib/facets/core/hash/graph.rb
facets-1.7.0 lib/facets/core/hash/graph.rb
facets-1.7.30 lib/facets/core/hash/graph.rb
facets-1.7.46 lib/facets/core/hash/graph.rb
facets-1.8.20 lib/facets/core/hash/graph.rb