Class: DecisionAgent::Dmn::Feel::Functions::Substring

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

Overview

STRING FUNCTIONS

Class Method Summary collapse

Methods inherited from Base

register, validate_arg_count

Class Method Details

.call(args, _context = {}) ⇒ Object



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

def self.call(args, _context = {})
  validate_arg_count(args, 2..3)
  str = args[0].to_s
  start_pos = args[1].to_i - 1 # FEEL is 1-indexed
  length = args[2]&.to_i

  return str[start_pos..] if length.nil?

  str[start_pos, length] || ""
end