Class: CloudSesame::Query::AST::DateValue

Inherits:
StringValue show all
Defined in:
lib/cloud_sesame/query/ast/date_value.rb

Constant Summary collapse

COMPILE_FORMAT =
'%FT%TZ'.freeze
DATETIME_FORMAT =
'%FT%T'.freeze
TIME_FORMAT =
'%F %T %z'.freeze
DATE_FORMAT =
'%F'.freeze

Constants inherited from StringValue

StringValue::ESCAPE_QUATE, StringValue::SINGLE_QUATE

Constants inherited from Abstract::Value

Abstract::Value::DIGIT_FORMAT, Abstract::Value::RANGE_FORMAT

Instance Attribute Summary

Attributes inherited from Abstract::Value

#changed, #compiled, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StringValue

#to_ary

Methods inherited from Abstract::Value

#==, #compile, datetime?, numeric?, range?, string_date?, string_datetime?, string_numeric?, string_range?, string_time?

Constructor Details

#initialize(value, type = nil) ⇒ DateValue

Returns a new instance of DateValue.



16
17
18
19
20
21
# File 'lib/cloud_sesame/query/ast/date_value.rb', line 16

def initialize(value, type = nil)
  value = Value.string_datetime?(value) ? parse_datetime(value) :
          Value.string_time?(value) ? parse_time(value) :
          Value.string_date?(value) ? parse_date(value) : value
  super(value, type)
end

Class Method Details

.parse(value) ⇒ Object



11
12
13
14
# File 'lib/cloud_sesame/query/ast/date_value.rb', line 11

def self.parse(value)
  return value.parse self if value.kind_of?(RangeValue)
  range?(value) || string_range?(value) ? RangeValue.new(value, self) : new(value)
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/cloud_sesame/query/ast/date_value.rb', line 23

def to_s
  compile
end