Sha256: c33152f831202a645394da8f4cdf6f1291c07d94f27a9c61ff9d600c746b47f1
Contents?: true
Size: 521 Bytes
Versions: 7
Compression:
Stored size: 521 Bytes
Contents
require 'set' # This is a hack that I don't want to ever use anywhere else or repeat EVER, but we need enums to be # an Array to pass schema validation. But we also want fast lookup! class ArraySet < Array def include?(obj) if !defined? @values @values = Set.new self.each { |x| @values << convert_to_float_if_numeric(x) } end @values.include?(convert_to_float_if_numeric(obj)) end private def convert_to_float_if_numeric(value) value.is_a?(Numeric) ? value.to_f : value end end
Version data entries
7 entries across 6 versions & 3 rubygems