class PunctuationMark
Класс который работает со знаками пунктуации
Public Instance Methods
add_comma(text)
click to toggle source
добавление запятых перед предлогами `а` и `но`
# File lib/rus_typograf/punctuation_mark.rb, line 17 def add_comma(text) text = text.gsub(/(?<!,)\sно\s/, ', но ') text = text.gsub(/(?<!,)\sа\s/, ', а ') end
replace_dots(text)
click to toggle source
меняем три точки на троеточик
# File lib/rus_typograf/punctuation_mark.rb, line 4 def replace_dots(text) text.gsub(/[.][.][.]/i, '…') end
replace_spaces(text)
click to toggle source
убираем пробелы перед знаками припинания
# File lib/rus_typograf/punctuation_mark.rb, line 9 def replace_spaces(text) text = text.gsub(/\s[.]/, '.') text = text.gsub(/\s[?]/, '?') text = text.gsub(/\s[!]/, '!') text = text.gsub(/\s[,]/, ',') end