Sha256: fda868d2260706ff4f27bad4297b75d3677e9b06cc45c389be540b173b4ae8b4

Contents?: true

Size: 497 Bytes

Versions: 25

Compression:

Stored size: 497 Bytes

Contents

unless Enumerable.method_defined?(:to_h)
  require 'backports/tools/arguments'
  require 'backports/1.9.2/enumerable/each_entry'

  module Enumerable
    def to_h(*args)
      h = {}
      each_entry(*args) do |key_value|
        key_value = Backports.coerce_to_ary(key_value)
        if key_value.size != 2
          raise ArgumentError, "element has wrong array length (expected 2, was #{key_value.size})"
        end
        h[ key_value[0] ] = key_value[1]
      end
      h
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
backports-3.25.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.24.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.24.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.23.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.22.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.22.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.21.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.20.2 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.20.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.20.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.19.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.18.2 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.18.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.18.0 lib/backports/2.1.0/enumerable/to_h.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/2.1.0/enumerable/to_h.rb
backports-3.17.2 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.17.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.17.0 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.16.1 lib/backports/2.1.0/enumerable/to_h.rb
backports-3.16.0 lib/backports/2.1.0/enumerable/to_h.rb