Sha256: 132e1d89c793a0d9ac89f1c61646732533fa686fb340245cdce3c669c6d317a8

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

require 'ssmd/processors'

module SSMD
  class Converter
    attr_reader :input

    def initialize(input)
      @input = input
    end

    def convert
      result = processors.inject(input) do |text, processor|
        process processor.new, text
      end

      "<speak>#{result.strip}</speak>"
    end

    def processors
      p = SSMD::Processors

      [
        p::EmphasisProcessor, p::AnnotationProcessor, p::MarkProcessor
      ]
    end

    def process(processor, input)
      if processor.matches? input
        process processor, processor.substitute(input)
      else
        input
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ssmd-0.1.0 lib/ssmd/converter.rb