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-4.10.5 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.10.4 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.10.3 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.10.2 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.10.1 lib/cassandra_object/types/date_type.rb
cassandra_object_rails-0.0.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.10.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.9.2 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.9.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.9.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.8.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.8.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.7.3 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.7.2 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.7.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.7.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.6.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.5.1 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.5.0 lib/cassandra_object/types/date_type.rb
gotime-cassandra_object-4.4.5 lib/cassandra_object/types/date_type.rb