Sha256: 1bb9d117dd899fdef2428167fccd74bc5aac3c8fbf7d3b90be1ffee8f7b849e0

Contents?: true

Size: 828 Bytes

Versions: 4

Compression:

Stored size: 828 Bytes

Contents

require_relative 'processor'

module SSMD::Processors
  class BreakProcessor < Processor
    def result
      name, value = attribute

      "<break #{name}=\"#{value}\"/>"
    end

    def text
      ""
    end

    def regex
      /(?<=\s)\.\.\.(?:(?<comma>c)|(?<sentence>s)|(?<paragraph>p)|(?<s>\d+s)|(?<ms>\d+ms)|(?<num>\d+))?(?=\s)/
    end

    def attribute
      if ms = (match[:num] || match[:ms])
        if ms == "0"
          ["strength", "none"]
        else
          ["time", "#{ms.to_i}ms"]
        end
      elsif s = match[:s]
        ["time", "#{s.to_i}s"]
      elsif match[:paragraph]
        ["strength", "x-strong"]
      elsif match[:sentence]
        ["strength", "strong"]
      elsif match[:comma]
        ["strength", "medium"]
      else
        ["strength", "x-strong"]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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