Sha256: 5d70754ad4c97004c63df25b5081fb9f6a2a2a36da5d3a2bd7578eba3610b7c2
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 Bytes
Contents
# Copyright (c) 2023 Jerome Arbez-Gindre # frozen_string_literal: true require('asciidoctor/extensions') unless RUBY_ENGINE == 'opal' require('ostruct') module Asciidoctor module DefMastership # Hosts several Text replacement rules class RegexpDispatcher Rule = Struct.new(:regexp, :method_symbol) private_constant :Rule def initialize(effective_subs) @effective_subs = effective_subs @rules = [] end def add_rule(regexp, method_symbol) @rules << Rule.new(regexp, method_symbol) self end def replace(line) @rules.each do |rule| matches = rule.regexp.match(line) return @effective_subs.__send__(rule.method_symbol, line, matches) if matches end [line] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
asciidoctor-defmastership-1.0.7 | lib/asciidoctor/defmastership/regexp_dispatcher.rb |
asciidoctor-defmastership-1.0.6 | lib/asciidoctor/defmastership/regexp_dispatcher.rb |