Class: Array
Instance Method Summary collapse
Instance Method Details
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/forkforge/internal/monkeypatches.rb', line 33 def to_h i = 0 self.inject({}) { |memo, e| raise TypeError.new("wrong element type #{e.class} at #{i} (expected array)") unless Array === e raise ArgumentError.new("wrong array length at #{i} (expected 2, was #{e.count})") unless e.count == 2 i += 1 memo[e.first] = e.last memo } end |