Class: DecisionAgent::Dmn::Feel::Types::Time

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

Overview

Wrapper for time values

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Time

Returns a new instance of Time.



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/decision_agent/dmn/feel/types.rb', line 102

def initialize(value)
  @value = case value
           when ::Time then value
           when String then parse_time(value)
           else
             raise FeelTypeError.new(
               "Cannot convert to Time",
               expected_type: "Time",
               actual_type: value.class,
               value: value
             )
           end
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



100
101
102
# File 'lib/decision_agent/dmn/feel/types.rb', line 100

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



120
121
122
123
124
# File 'lib/decision_agent/dmn/feel/types.rb', line 120

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

  @value == other
end

#inspectObject



126
127
128
# File 'lib/decision_agent/dmn/feel/types.rb', line 126

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

#to_rubyObject



116
117
118
# File 'lib/decision_agent/dmn/feel/types.rb', line 116

def to_ruby
  @value
end