Class: PrettyStrings::Cleaner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Cleaner

Returns a new instance of Cleaner.



6
7
8
# File 'lib/pretty_strings.rb', line 6

def initialize(text)
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/pretty_strings.rb', line 5

def text
  @text
end

Instance Method Details

#prettyObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pretty_strings.rb', line 10

def pretty
  return '' if text.nil? || text.empty?
  remove_bracketed_numbers(
    remove_consecutive_dots(
    replace_symbol_with_bracket(
    remove_newlines(
    replace_tabs(
    remove_bracketed_code(
    remove_twb_tags(
    scan_for_code(
    escape_text(
    sanitize_text(
    replace_bracket_with_symbol(
    escape_text(
    sanitize_text(
    replace_bracket_with_symbol(
    text
  )))))))))))))).squeeze(" ").strip
end