Class: Birddog::DateExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/birddog/date_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ DateExpression

Returns a new instance of DateExpression.



6
7
8
9
10
# File 'lib/birddog/date_expression.rb', line 6

def initialize(value)
  value.gsub!(/\s/, '')
  parts = value.scan(/(?:[=<>]+|(?:[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}))/)[0,2]
  @value = Date.parse(Chronic.parse(parts.last).to_s)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/birddog/date_expression.rb', line 4

def value
  @value
end

Instance Method Details

#to_sObject



12
13
14
# File 'lib/birddog/date_expression.rb', line 12

def to_s
  @value.to_s
end