Sha256: c647ef76c5eb5eec3660bccb714a15869f8280ca5fbd83eb741d63707371cbfb

Contents?: true

Size: 835 Bytes

Versions: 4

Compression:

Stored size: 835 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) ? 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

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
CloudSesame-0.7.10 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.9 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.8 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.7 lib/cloud_sesame/query/ast/value.rb