class Playwright::CLI::Utils::Display::Display
Constants
- DEFAULT_COLOR
- ERROR_COLOR
- InvalidPrintMethod
- VALID_PRINT_METHODS
- WARNING_COLOR
Public Instance Methods
abort(msg = nil)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 27 def abort msg = nil print msg, color: WARNING_COLOR if msg print "Action Cancelled.", color: WARNING_COLOR exit 1 end
error(msg, msg2 = nil)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 20 def error msg, msg2 = nil print msg, color: ERROR_COLOR print "Action Cancelled.", color: ERROR_COLOR print msg2, color: ERROR_COLOR if msg2 exit 1 end
print(msg, method: :puts, color: DEFAULT_COLOR, indent: false)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 33 def print msg, method: :puts, color: DEFAULT_COLOR, indent: false msg = stringify msg, indent: indent validate_print_method!(method) msg = msg.send(color) if defined?(Colorize) && msg send(method, msg) end
Private Instance Methods
indentify(msg, count: 0)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 59 def indentify msg, count: 0 "#{" " * count}#{msg}" end
stringify(msg, indent: false)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 46 def stringify msg, indent: false indent = 1 if indent == true case msg when String indent ? indentify(msg, count: indent) : msg when Array msg = msg.map { |ln| indentify(ln, count: indent) } if indent msg.join("\n") else msg.to_s end end
validate_print_method!(method)
click to toggle source
# File lib/playwright/cli/utils/display.rb, line 42 def validate_print_method!(method) raise InvalidPrintMethod unless VALID_PRINT_METHODS.include? method.to_sym end