class Mustermann::Sinatra

@see file:README.md#sinatra Syntax description in the README
@see Mustermann::Pattern
Mustermann.new(‘/:foo’) === ‘/bar’ # => true
@example
Sinatra 2.0 style pattern implementation.

def self.escape(string)

Returns:
  • (String) - the escaped string

Parameters:
  • string (#to_s) -- the input string
def self.escape(string)
  string.to_s.gsub(/[\?\(\)\*:\\\|\{\}]/) { |c| "\\#{c}" }
end

def self.try_convert(input, **options)

Returns:
  • (Mustermann::Sinatra, nil) - the converted pattern, if possible
def self.try_convert(input, **options)
  TryConvert.convert(input, **options)
end

def native_concat(other)

@!visibility private
def native_concat(other)
  return unless converted = self.class.try_convert(other, **options)
  safe_string + converted.safe_string
end

def safe_string

Returns:
  • (String) - string representatin of the pattern
def safe_string
  @safe_string ||= SafeRenderer.translate(to_ast)
end

def |(other)

Other tags:
    See: Mustermann::Pattern#| -

Returns:
  • (Mustermann::Pattern) - a composite pattern

Parameters:
  • other (Mustermann::Pattern, String) -- the other pattern
def |(other)
  return super unless converted = self.class.try_convert(other, **options)
  return super unless converted.names.empty? or names.empty?
  self.class.new(safe_string + "|" + converted.safe_string, **options)
end