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