Sha256: 59412e66894488215f01548d38afef8917518bb7dcbb3dc72a8ca8cddae85e52

Contents?: true

Size: 824 Bytes

Versions: 31

Compression:

Stored size: 824 Bytes

Contents

class Array

  ##
  # Transforms an Array of key/value pairs into a Hash
  #
  # This is a better idiom than using Hash[*array.flatten] in Ruby 1.8.6
  # because it is not possible to limit the flattening to a single
  # level.
  #
  # @return [Hash]
  #   A Hash where each entry in the Array is turned into a key/value
  #
  # @api public
  def to_hash
    h = {}
    each { |k,v| h[k] = v }
    h
  end

  ##
  # Transforms an Array of key/value pairs into a Mash
  #
  # This is a better idiom than using Mash[*array.flatten] in Ruby 1.8.6
  # because it is not possible to limit the flattening to a single
  # level.
  #
  # @return [Mash]
  #   A Hash where each entry in the Array is turned into a key/value
  #
  # @api public
  def to_mash
    m = Mash.new
    each { |k,v| m[k] = v }
    m
  end
end # class Array

Version data entries

31 entries across 30 versions & 6 rubygems

Version Path
dm-core-1.1.0.rc2 lib/dm-core/core_ext/array.rb
dm-core-1.1.0.rc1 lib/dm-core/core_ext/array.rb
dm-core-1.0.2 lib/dm-core/core_ext/array.rb
dm-core-1.0.1 lib/dm-core/core_ext/array.rb
dm-core-1.0.0 lib/dm-core/core_ext/array.rb
dm-core-1.0.0.rc3 lib/dm-core/core_ext/array.rb
dm-core-1.0.0.rc2 lib/dm-core/core_ext/array.rb
dm-core-1.0.0.rc1 lib/dm-core/core_ext/array.rb
sundbp-extlib-0.9.14 lib/extlib/array.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/extlib-0.9.14/lib/extlib/array.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/extlib-0.9.14/lib/extlib/array.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/array.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/array.rb
extlib-0.9.14 lib/extlib/array.rb
ginst-2009.12.8 vendor/gems/extlib-0.9.13/lib/extlib/array.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/array.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/array.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/array.rb
ginst-2009.11.24 vendor/gems/extlib-0.9.13/lib/extlib/array.rb
ginst-2009.11.23 vendor/gems/extlib-0.9.13/lib/extlib/array.rb