Module: Piola::Parsing
- Defined in:
- lib/piola/parsing.rb
Instance Method Summary collapse
-
#remove_all_parenthesis(strip = true) ⇒ Object
Remove all parenthesis types.
-
#remove_enters ⇒ Object
Remove enters.
-
#remove_extra_enters ⇒ Object
Removes extra enters.
-
#remove_quotes ⇒ Object
Remove quotes.
Instance Method Details
#remove_all_parenthesis(strip = true) ⇒ Object
Remove all parenthesis types
8 9 10 11 12 13 14 15 16 |
# File 'lib/piola/parsing.rb', line 8 def remove_all_parenthesis(strip = true) str = self str = str.gsub(/\[.*\]/, "") str = str.gsub(/\(.*\)/, '') str = str.gsub(/\{.*\}/, '') str = str.strip if strip str = str.gsub(/ +/, ' ') str end |
#remove_enters ⇒ Object
Remove enters
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/piola/parsing.rb', line 19 def remove_enters str = self str = str.gsub("\n", " ") str = str.gsub("\r", " ") str = str.gsub(10.chr, " ") str = str.gsub(13.chr, " ") str = str.gsub("<br />", " ") str = str.gsub("<br>", " ") str = str.gsub("<br/>", " ") str = str.gsub("<BR />", " ") str = str.gsub("<BR>", " ") str = str.gsub("<BR/>", " ") str = str.gsub(/( )+/, ' ') str = str.strip str end |
#remove_extra_enters ⇒ Object
Removes extra enters
37 38 39 40 41 |
# File 'lib/piola/parsing.rb', line 37 def remove_extra_enters self.split("\n").map do |p| p.strip if p.present? end.compact.join("\n") end |
#remove_quotes ⇒ Object
Remove quotes
44 45 46 47 48 49 |
# File 'lib/piola/parsing.rb', line 44 def remove_quotes str = self str = str.gsub('"', '') str = str.gsub("'", '') str end |