Class: Mustermann::Regular

Inherits:
RegexpBased show all
Defined in:
lib/mustermann/regular.rb

Overview

Regexp pattern implementation.

Examples:

Mustermann.new('/.*', type: :regexp) === '/bar' # => true

See Also:

Constant Summary

Constants included from Mustermann

CompileError, DEFAULT_TYPE, Error, ExpandError, ParseError

Instance Attribute Summary

Attributes inherited from RegexpBased

#regexp

Attributes inherited from Pattern

#uri_decode

Instance Method Summary collapse

Methods inherited from RegexpBased

#peek_match, #peek_size

Methods inherited from Pattern

#+, #==, #===, #=~, #eql?, #expand, #hash, #match, #named_captures, #names, new, #params, #peek, #peek_match, #peek_params, #peek_size, supported?, supported_options, #to_proc, #to_s, #to_templates, #|

Methods included from Mustermann

[], new

Constructor Details

#initialize(string, check_anchors: true, **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:



22
23
24
25
26
27
# File 'lib/mustermann/regular.rb', line 22

def initialize(string, check_anchors: true, **options)
  string = $1 if string.to_s =~ /\A\(\?\-mix\:(.*)\)\Z/ && string.inspect == "/#$1/"
  string = string.source.gsub!(/(?<!\\)(?:\s|#.*$)/, '') if extended_regexp?(string)
  @check_anchors = check_anchors
  super(string, **options)
end