class Bosh::Cli::TaskTracking::SmartWhitespacePrinter
Constants
- SPACE_BETWEEN_LAST_SEP_AND_SEP
- VALID_SEPARATORS
Public Class Methods
new()
click to toggle source
# File lib/cli/task_tracking/smart_whitespace_printer.rb, line 29 def initialize @buffer = StringIO.new @last_sep = :start end
Public Instance Methods
finish()
click to toggle source
# File lib/cli/task_tracking/smart_whitespace_printer.rb, line 50 def finish if VALID_SEPARATORS.include?(@last_sep) @buffer.print("\n") end end
output()
click to toggle source
# File lib/cli/task_tracking/smart_whitespace_printer.rb, line 46 def output @buffer.string.tap { @buffer.string = '' } end
print(separator, msg)
click to toggle source
# File lib/cli/task_tracking/smart_whitespace_printer.rb, line 34 def print(separator, msg) unless VALID_SEPARATORS.include?(separator) raise ArgumentError, "Unknown separator #{separator.inspect}" end space = SPACE_BETWEEN_LAST_SEP_AND_SEP[[@last_sep, separator]] @buffer.print(space) if space @last_sep = separator @buffer.print(msg) end