Class: RegularExpression::Pattern
- Inherits:
-
Object
- Object
- RegularExpression::Pattern
- Defined in:
- lib/regular_expression/pattern.rb
Instance Attribute Summary collapse
-
#bytecode ⇒ Object
readonly
Returns the value of attribute bytecode.
Instance Method Summary collapse
- #compile(compiler: Generator::X86) ⇒ Object
-
#initialize(source) ⇒ Pattern
constructor
A new instance of Pattern.
- #match?(string) ⇒ Boolean
Constructor Details
Instance Attribute Details
#bytecode ⇒ Object (readonly)
Returns the value of attribute bytecode.
5 6 7 |
# File 'lib/regular_expression/pattern.rb', line 5 def bytecode @bytecode end |
Instance Method Details
#compile(compiler: Generator::X86) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/regular_expression/pattern.rb', line 12 def compile(compiler: Generator::X86) cfg = CFG.build(bytecode) singleton_class.undef_method(:match?) define_singleton_method(:match?, &compiler.compile(cfg)) end |
#match?(string) ⇒ Boolean
19 20 21 |
# File 'lib/regular_expression/pattern.rb', line 19 def match?(string) Interpreter.new(bytecode).match?(string) end |