Class: Imap::Backup::Text::Sanitizer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/imap/backup/text/sanitizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Sanitizer

Returns a new instance of Sanitizer.



16
17
18
19
# File 'lib/imap/backup/text/sanitizer.rb', line 16

def initialize(output)
  @output = output
  @current = ""
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



11
12
13
# File 'lib/imap/backup/text/sanitizer.rb', line 11

def output
  @output
end

Instance Method Details

#flushObject



33
34
35
36
37
38
# File 'lib/imap/backup/text/sanitizer.rb', line 33

def flush
  return if @current == ""

  clean = sanitize(@current)
  output.puts clean
end


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/imap/backup/text/sanitizer.rb', line 21

def print(*args)
  @current << args.join
  loop do
    line, newline, rest = @current.partition("\n")
    break if newline != "\n"

    clean = sanitize(line)
    output.puts clean
    @current = rest
  end
end