Class: Mustermann::Set::Trie::Translator

Inherits:
AST::Translator
  • Object
show all
Defined in:
lib/mustermann/set/trie.rb

Constant Summary

Constants inherited from AST::Translator

AST::Translator::URI_PARSER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Translator

Returns a new instance of Translator.



56
57
58
59
60
61
# File 'lib/mustermann/set/trie.rb', line 56

def initialize(pattern)
  @pattern  = pattern
  @compiler = pattern.compiler.new
  @options  = pattern.options
  super()
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



54
55
56
# File 'lib/mustermann/set/trie.rb', line 54

def pattern
  @pattern
end

Instance Method Details

#compile(node, **options) ⇒ Object

G anchors to a position passed to String#match, avoiding substring allocation.



64
# File 'lib/mustermann/set/trie.rb', line 64

def compile(node, **options) = /\G#{@compiler.translate(node, **@options, **options)}/