Sha256: d2b55df0b7dcde1057e2336f74a201d2c81eab727d301415bc368d8753f08389

Contents?: true

Size: 972 Bytes

Versions: 4

Compression:

Stored size: 972 Bytes

Contents

module CloudSesame
  module Query
    module AST
      class Value < Abstract::Value

        TYPES = {
          string: StringValue,
          numeric: NumericValue,
          datetime: DateValue
        }

        def self.map_type(symbol)
          (klass =TYPES[symbol]) ? klass : self
        end

        def self.parse(value)
          return value.parse self if value.kind_of?(RangeValue)
          (
            range_value?(value) ? RangeValue :
            numeric_value?(value) ? NumericValue :
            datetime_value?(value) ? DateValue : StringValue
          ).new(value, self)
        end

        def self.range_value?(value)
          range?(value) || string_range?(value)
        end

        def self.numeric_value?(value)
          numeric?(value) #|| string_numeric?(value)
        end

        def self.datetime_value?(value)
          datetime?(value) || string_datetime?(value) || string_time?(value)
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
CloudSesame-1.0.1 lib/cloud_sesame/query/ast/value.rb
CloudSesame-1.0.0 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.9.4 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.9.3 lib/cloud_sesame/query/ast/value.rb