class Mustermann::AST::Compiler::Capture

Capture compilation is complex. :( @!visibility private

Public Instance Methods

pattern(capture: nil, **options) click to toggle source

@return [String] regexp without the named capture @!visibility private

# File lib/mustermann/ast/compiler.rb, line 49
def pattern(capture: nil, **options)
  case capture
  when Symbol then from_symbol(capture, **options)
  when Array  then from_array(capture, **options)
  when Hash   then from_hash(capture, **options)
  when String then from_string(capture, **options)
  when nil    then from_nil(**options)
  else capture
  end
end
translate(**options) click to toggle source

@!visibility private

# File lib/mustermann/ast/compiler.rb, line 42
def translate(**options)
  return pattern(options) if options[:no_captures]
  "(?<#{name}>#{translate(no_captures: true, **options)})"
end