Class: Imap::Backup::Sanitizer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Sanitizer

Returns a new instance of Sanitizer.


12
13
14
15
# File 'lib/imap/backup/sanitizer.rb', line 12

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

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.


7
8
9
# File 'lib/imap/backup/sanitizer.rb', line 7

def output
  @output
end

Instance Method Details

#flushObject


29
30
31
32
33
34
# File 'lib/imap/backup/sanitizer.rb', line 29

def flush
  return if @current == ""

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

17
18
19
20
21
22
23
24
25
26
27
# File 'lib/imap/backup/sanitizer.rb', line 17

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