Sha256: db705f764cbd0636e55a7e7d8c4da459919bd7dd71b53b007b45949073aab932
Contents?: true
Size: 515 Bytes
Versions: 1
Compression:
Stored size: 515 Bytes
Contents
module CassandraObject class 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gotime-cassandra_object-2.1.0 | lib/cassandra_object/types/float_type.rb |