Sha256: eeb67845718269a8a739f3ff3b7d2227671ffb0bc0575706cb9acd63bba68c8a
Contents?: true
Size: 516 Bytes
Versions: 117
Compression:
Stored size: 516 Bytes
Contents
module CassandraObject module Types module FloatType REGEX = /\A[-+]?\d+(\.\d+)?\Z/ def encode(float) raise ArgumentError.new("#{self} requires a Float") unless float.kind_of?(Float) float.to_s end module_function :encode def decode(str) return nil if str.empty? raise ArgumentError.new("Cannot convert #{str} into a Float") unless str.kind_of?(String) && str.match(REGEX) str.to_f end module_function :decode end end end
Version data entries
117 entries across 117 versions & 2 rubygems