Class: DecisionAgent::Dmn::Feel::Types::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/dmn/feel/types.rb

Overview

Wrapper for dates (ISO 8601)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Date

Returns a new instance of Date.



56
57
58
59
60
61
62
63
# File 'lib/decision_agent/dmn/feel/types.rb', line 56

def initialize(value)
  @value = case value
           when ::Time, ::Date, ::DateTime then value
           when String then parse_date(value)
           else
             raise FeelTypeError, "Cannot convert #{value.class} to Date: #{value.inspect}"
           end
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



54
55
56
# File 'lib/decision_agent/dmn/feel/types.rb', line 54

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



69
70
71
72
73
# File 'lib/decision_agent/dmn/feel/types.rb', line 69

def ==(other)
  return @value == other.value if other.is_a?(Date)

  @value == other
end

#inspectObject



75
76
77
# File 'lib/decision_agent/dmn/feel/types.rb', line 75

def inspect
  "#<Feel::Date #{@value}>"
end

#to_rubyObject



65
66
67
# File 'lib/decision_agent/dmn/feel/types.rb', line 65

def to_ruby
  @value
end