Sha256: 12fbffb117bc9c6c4afda63a3a32786008c26eec20f46db8c10a17dfa0c4451c

Contents?: true

Size: 971 Bytes

Versions: 10

Compression:

Stored size: 971 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

10 entries across 10 versions & 1 rubygems

Version Path
CloudSesame-0.9.2 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.9.1 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.9.0 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.8.3 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.8.2 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.8.1 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.8.0 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.13 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.12 lib/cloud_sesame/query/ast/value.rb
CloudSesame-0.7.11 lib/cloud_sesame/query/ast/value.rb