class Spoom::Printer
Attributes
out[RW]
Public Class Methods
new(out: $stdout, colors: true, indent_level: 0)
click to toggle source
# File lib/spoom/printer.rb, line 17 def initialize(out: $stdout, colors: true, indent_level: 0) @out = out @colors = colors @indent_level = indent_level end
Public Instance Methods
colorize(string, color)
click to toggle source
# File lib/spoom/printer.rb, line 76 def colorize(string, color) @colors ? string.colorize(color) : string end
dedent()
click to toggle source
# File lib/spoom/printer.rb, line 31 def dedent @indent_level -= 2 end
indent()
click to toggle source
# File lib/spoom/printer.rb, line 25 def indent @indent_level += 2 end
print(string)
click to toggle source
# File lib/spoom/printer.rb, line 37 def print(string) return unless string @out.print(string) end
print_colored(string, color, *colors)
click to toggle source
# File lib/spoom/printer.rb, line 46 def print_colored(string, color, *colors) return unless string string = colorize(string, color) colors.each { |c| string = colorize(string, c) } @out.print(string) end
printl(string)
click to toggle source
# File lib/spoom/printer.rb, line 61 def printl(string) return unless string printt print(string) printn end
printn()
click to toggle source
# File lib/spoom/printer.rb, line 55 def printn print("\n") end
printt()
click to toggle source
# File lib/spoom/printer.rb, line 70 def printt print(" " * @indent_level) end