class Nydp::Builtin::StringMatch

Public Instance Methods

builtin_call(target, pattern) click to toggle source
# File lib/nydp/builtin/string_match.rb, line 4
def builtin_call target, pattern
  target  = target.to_s
  pattern = Regexp.new(pattern.to_s) unless pattern.is_a? Regexp
  match   = pattern.match target

  if match
    { match: match.to_s, captures: (match.captures.map(&:to_s)._nydp_wrapper) }
  end
end