Class: Mustermann::RegexpBased Abstract

Inherits:
Pattern
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mustermann/regexp_based.rb

Overview

This class is abstract.

Superclass for patterns that internally compile to a regular expression.

See Also:

Direct Known Subclasses

AST::Pattern, Regular, Simple

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Pattern

#===, #=~, #expand, #match, #named_captures, #names, new, #params, supported?, supported_options, #to_s

Methods included from Mustermann

[], new

Constructor Details

#initialize(string, **options) ⇒ Pattern

Returns a new instance of Pattern.

Parameters:

  • string (String)

    the string representation of the pattern

  • options (Hash)

    options for fine-tuning the pattern behavior

See Also:



16
17
18
19
# File 'lib/mustermann/regexp_based.rb', line 16

def initialize(string, **options)
  super
  @regexp = compile(**options)
end

Instance Attribute Details

#regexpRegexp (readonly) Also known as: to_regexp

Returns regular expression equivalent to the pattern.

Returns:

  • (Regexp)

    regular expression equivalent to the pattern.



10
11
12
# File 'lib/mustermann/regexp_based.rb', line 10

def regexp
  @regexp
end