Sha256: 22d5f1dc6e5064ff1052771c15005bd4c794666780444050e96e4e7769ef4479
Contents?: true
Size: 887 Bytes
Versions: 2
Compression:
Stored size: 887 Bytes
Contents
# encoding: utf-8 unless NilClass.respond_to? :strip class NilClass def strip nil end def match *args false end end end class Object def vacant? self.nil? || self.respond_to?(:strip) && self.strip.empty? || self.respond_to?(:zero?) && self.zero? || Array === self && self.compact.empty? end end unless Hash.respond_to? :take class Hash def take count, from = 0 Hash[self.to_a[from..from+count]] end end end unless Array.respond_to? :to_h class Array 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
forkforge-0.0.4 | lib/forkforge/internal/monkeypatches.rb |
forkforge-0.0.3 | lib/forkforge/internal/monkeypatches.rb |