Sha256: c3454d4572fcd8e7df3b3e3d6c1e71f2c5a3257c16b184870f0c5bab12bc35f2
Contents?: true
Size: 538 Bytes
Versions: 1
Compression:
Stored size: 538 Bytes
Contents
module CassandraObject class Types module IntegerType REGEX = /\A[-+]?\d+\Z/ def encode(int) raise ArgumentError.new("#{self} requires an Integer. You passed #{int.inspect}") unless int.kind_of?(Integer) int.to_s end module_function :encode def decode(str) return nil if str.empty? raise ArgumentError.new("Cannot convert #{str} into an Integer") unless str.kind_of?(String) && str.match(REGEX) str.to_i 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/integer_type.rb |