Sha256: a8e4f7300199129b9b95c045e11a91a3c8899cfe4b621330bf84d5a5b9dac2c6

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

module SSMD::Processors
  class Processor
    attr_reader :match

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

      !match.nil?
    end

    def substitute(input)
      if match
        match.pre_match + result + match.post_match
      end
    end

    def strip_ssmd(input)
      if match
        match.pre_match + text + match.post_match
      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

4 entries across 4 versions & 1 rubygems

Version Path
ssmd-0.4.0 lib/ssmd/processors/processor.rb
ssmd-0.3.1 lib/ssmd/processors/processor.rb
ssmd-0.3.0 lib/ssmd/processors/processor.rb
ssmd-0.2.3 lib/ssmd/processors/processor.rb