Sha256: e4072f49e8a1db5ce559289ff037c0bc307ac9f32c92db15865e1abb5cb626bc
Contents?: true
Size: 783 Bytes
Versions: 1
Compression:
Stored size: 783 Bytes
Contents
require 'mustermann/pattern' require 'forwardable' module Mustermann # Superclass for patterns that internally compile to a regular expression. # @see Pattern # @abstract class RegexpBased < Pattern # @return [Regexp] regular expression equivalent to the pattern. attr_reader :regexp alias_method :to_regexp, :regexp # @param (see Pattern#initialize) # @return (see Pattern#initialize) # @see (see Pattern#initialize) def initialize(string, **options) @regexp = compile(string, **options) super end extend Forwardable def_delegators :regexp, :===, :=~, :match, :names, :named_captures def compile(string, **options) raise NotImplementedError, 'subclass responsibility' end private :compile end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mustermann-0.0.1 | lib/mustermann/regexp_based.rb |