Sha256: e683f029f24c9ec92afe3cf0f18d5af256d16c20043a6db533e590553f325d9e

Contents?: true

Size: 367 Bytes

Versions: 47

Compression:

Stored size: 367 Bytes

Contents

module CassandraObject
  module Types
    class DateType < BaseType
      FORMAT = '%Y-%m-%d'
      REGEX = /\A\d{4}-\d{2}-\d{2}\Z/

      def encode(value)
        raise ArgumentError.new("#{value.inspect} is not a Date") unless value.kind_of?(Date)
        value.strftime(FORMAT)
      end

      def decode(str)
        Date.parse(str)
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
gotime-cassandra_object-2.12.4 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.12.3 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.12.2 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.12.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.12.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.11.9 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-2.11.8 lib/cassandra_object/types/date_type.rb