Module: Cleaners
- Defined in:
- lib/docx/cleaners.rb
Class Method Summary collapse
- .ending_tags_without_spaces_cleaner(str) ⇒ Object
- .join_dots_and_brackets_cleaner(str) ⇒ Object
- .no_spaces_around_undeline_cleaner(str) ⇒ Object
- .question_method_cleaner(str) ⇒ Object
- .single_quote_cleaner(str) ⇒ Object
- .starting_tags_without_spaces_cleaner(str) ⇒ Object
- .var_without_duplicated_spaces_cleaner(str) ⇒ Object
- .var_without_spaces_inside_brackets_cleaner(str) ⇒ Object
Class Method Details
.ending_tags_without_spaces_cleaner(str) ⇒ Object
6 7 8 |
# File 'lib/docx/cleaners.rb', line 6 def self.(str) str && str.gsub(/%\s*\}\s*\}/, '%}}') end |
.join_dots_and_brackets_cleaner(str) ⇒ Object
26 27 28 |
# File 'lib/docx/cleaners.rb', line 26 def self.join_dots_and_brackets_cleaner(str) str && str.gsub(/\s*\.\s*/, '.').gsub(/\s*\[\s*/, '[').gsub(/\s*\]/, ']') end |
.no_spaces_around_undeline_cleaner(str) ⇒ Object
22 23 24 |
# File 'lib/docx/cleaners.rb', line 22 def self.no_spaces_around_undeline_cleaner(str) str && str.gsub(/\s*\_\s*/, "_") end |
.question_method_cleaner(str) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/docx/cleaners.rb', line 30 def self.question_method_cleaner(str) if str && str =~ /\A\{\{\s+if\s*(.*?)\s*\?\s+\}\}\Z/ "{{ if #{$1}\? }}" else str end end |
.single_quote_cleaner(str) ⇒ Object
10 11 12 |
# File 'lib/docx/cleaners.rb', line 10 def self.single_quote_cleaner(str) str && str.gsub(/\‘/, '\'').gsub(/\’/, '\'') end |
.starting_tags_without_spaces_cleaner(str) ⇒ Object
2 3 4 |
# File 'lib/docx/cleaners.rb', line 2 def self.(str) str && str.gsub(/\{\s*\{\s*%/, '{{%') end |
.var_without_duplicated_spaces_cleaner(str) ⇒ Object
14 15 16 |
# File 'lib/docx/cleaners.rb', line 14 def self.var_without_duplicated_spaces_cleaner(str) str && str.gsub(/\s+/, ' ') end |
.var_without_spaces_inside_brackets_cleaner(str) ⇒ Object
18 19 20 |
# File 'lib/docx/cleaners.rb', line 18 def self.var_without_spaces_inside_brackets_cleaner(str) str && str.gsub(/\[(.*?)\]/) { |match| match.gsub(/\s/, '')} end |