Class: FEEL::AtLiteral

Inherits:
Node
  • Object
show all
Defined in:
lib/feel/nodes.rb

Instance Method Summary collapse

Methods inherited from Node

#access_property, #qualified_names_in_context, #raise_evaluation_error

Instance Method Details

#eval(_context = {}) ⇒ Object



445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/feel/nodes.rb', line 445

def eval(_context = {})
  value = string_literal.eval
  return nil if value.nil?
  case value
  when /\AP/
    ActiveSupport::Duration.parse(value)
  when /\A\d{4}-\d{2}-\d{2}T/
    DateTime.parse(value)
  when /\A\d{4}-\d{2}-\d{2}\z/
    Date.parse(value)
  when /\A\d{2}:\d{2}/
    Time.parse(value)
  end
end