Sha256: f694e1781857abf3e0ac97978697807afedf66235d55d94cf5b3d0aa8c8f5b0d

Contents?: true

Size: 343 Bytes

Versions: 2

Compression:

Stored size: 343 Bytes

Contents

class Array
  # Translates an array into a hash, where each element of the array is
  # an array with 2 elements:
  #
  #   >> [[:key, :value], [1, 2], ['key', 'value']].to_h
  #   => {:key => :value, 1 => 2, 'key' => 'value}
  #
  def to_h
    returning({}) do |result|
      each do |(k, v)|
        result[k] = v
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Empact-roxml-2.0 lib/roxml/array.rb
Empact-roxml-2.1 lib/roxml/array.rb