Sha256: fdf6180794d7283ad1e421b4f7de13f01d6b18181db764e3a8c203d0e86c9a13

Contents?: true

Size: 414 Bytes

Versions: 10

Compression:

Stored size: 414 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 wrap(record, name, value)
        value.to_i
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.12.1 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.12.0 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.6 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.5 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.4 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.3 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.2 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.1 lib/cassandra_object/types/integer_type.rb
gotime-cassandra_object-4.11.0 lib/cassandra_object/types/integer_type.rb