Sha256: 2a7ed153414b4de32aa7baae5ca155543379eb86e605f5b5393a3eb1da3ee9c0

Contents?: true

Size: 404 Bytes

Versions: 21

Compression:

Stored size: 404 Bytes

Contents

module CassandraObject
  module Types
    class IntegerType < BaseType
      REGEX = /\A[-+]?\d+\Z/
      def encode(int)
        raise ArgumentError.new("#{int.inspect} is not an Integer.") unless int.kind_of?(Integer)
        int.to_s
      end

      def decode(str)
        return nil if str.empty?
        str.to_i
      end

      def typecast(value)
        value.to_i
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.0.0 lib/cassandra_object/types/integer_type.rb