Sha256: 2c5bc4215e72951c485c636052e3343ffd0b86a522e3a229796a27a5877974de

Contents?: true

Size: 680 Bytes

Versions: 5

Compression:

Stored size: 680 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
      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

5 entries across 5 versions & 1 rubygems

Version Path
ssmd-0.7.1 lib/ssmd/processors/processor.rb
ssmd-0.7.0 lib/ssmd/processors/processor.rb
ssmd-0.6.1 lib/ssmd/processors/processor.rb
ssmd-0.6.0 lib/ssmd/processors/processor.rb
ssmd-0.5.0 lib/ssmd/processors/processor.rb