Class: PunctuationMark

Inherits:
Object
  • Object
show all
Defined in:
lib/rus_typograf/punctuation_mark.rb

Overview

Класс который работает со знаками пунктуации

Instance Method Summary collapse

Instance Method Details

#add_comma(text) ⇒ Object

добавление запятых перед предлогами ‘а` и `но`



17
18
19
20
# 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) ⇒ Object

меняем три точки на троеточик



4
5
6
# File 'lib/rus_typograf/punctuation_mark.rb', line 4

def replace_dots(text)
	text.gsub(/[.][.][.]/i, '')
end

#replace_spaces(text) ⇒ Object

убираем пробелы перед знаками припинания



9
10
11
12
13
14
# 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