Sha256: 1a11b8dc0ccb178bbd3a0a22d6fae296ea850f6b9c3d7010e2be4b8412445c04
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
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 private def join_parts(prefix, text, suffix) leading_ws = /\A\s/ trailing_ws = /\s\z/ if prefix =~ trailing_ws && suffix =~ leading_ws && text == "" prefix.sub(trailing_ws, "") + suffix else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ssmd-0.7.5 | lib/ssmd/processors/break_processor.rb |