Sha256: c553f95aea66be5826fd4239e4be5b948b4f63b931af933046bc50848aba9e26

Contents?: true

Size: 690 Bytes

Versions: 3

Compression:

Stored size: 690 Bytes

Contents

module SSMD::Processors
  class Processor
    attr_reader :match, :options

    def initialize(options = {})
      @options = options
    end

    def matches?(input)
      @match = regex.match input

      !match.nil?
    end

    def substitute(input)
      if match
        [match.pre_match, result, match.post_match].join
      end
    end

    def strip_ssmd(input)
      if match
        [match.pre_match, text, match.post_match].join
      end
    end

    def text
      match.captures.first
    end

    def result
      raise "subclass responsibility"
    end

    def regex
      raise "subclass responsibility"
    end

    def warnings
      @warnings ||= []
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ssmd-0.7.4 lib/ssmd/processors/processor.rb
ssmd-0.7.3 lib/ssmd/processors/processor.rb
ssmd-0.7.2 lib/ssmd/processors/processor.rb