Sha256: 77d763cbd6d81e735ddb7ae785472de7a0ebb1129fed3deed938e510b8f39d49

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 Bytes

Contents

require "date"

module FilterParam
  module AST
    module Literals
      class Date < Literal
        def initialize(value)
          @value = ::Date.iso8601(value.to_s)
        rescue ::Date::Error
          raise FilterParam::InvalidLiteral.new("Invalid ISO8601 Date: #{value}")
        end

        def data_type
          :date
        end

        private

        def to_string
          Literals::String.new(value)
        end

        def to_date
          self
        end

        def to_datetime
          Literals::DateTime.new(value)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filter_param-0.1.2 lib/filter_param/ast/literals/date.rb