Class: Nydp::Builtin::StringMatch

Inherits:
Object
  • Object
show all
Includes:
Base, Singleton
Defined in:
lib/nydp/builtin/string_match.rb

Instance Method Summary collapse

Methods included from Base

#call, #handle_error, ignore_errors, #inspect, #name, #nydp_type, #to_s

Methods included from Helper

#cons, #list, #literal?, #pair?, #sig, #sym, #sym?

Methods included from Converter

#n2r, #r2n, #rubify

Instance Method Details

#builtin_call(target, pattern) ⇒ Object



4
5
6
7
8
9
10
11
12
# 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