Sha256: 7243e880214ed1dc0d7e7cce7b249b983df217c4817d026b7c0cc1dd0fbd9659
Contents?: true
Size: 455 Bytes
Versions: 11
Compression:
Stored size: 455 Bytes
Contents
module CassandraObject module Types class 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 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 end end end
Version data entries
11 entries across 11 versions & 1 rubygems