Class: Playwright::CLI::Utils::Display::Display
- Defined in:
- lib/playwright/cli/utils/display.rb
Constant Summary collapse
- InvalidPrintMethod =
Class.new StandardError
- VALID_PRINT_METHODS =
[:p, :puts, :print]
- DEFAULT_COLOR =
:green
- WARNING_COLOR =
:yellow
- ERROR_COLOR =
:red
Instance Method Summary collapse
- #abort(msg = nil) ⇒ Object
- #error(msg, msg2 = nil) ⇒ Object
- #print(msg, method: :puts, color: DEFAULT_COLOR, indent: false) ⇒ Object
Methods inherited from Util
Instance Method Details
#abort(msg = nil) ⇒ Object
27 28 29 30 31 |
# 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) ⇒ Object
20 21 22 23 24 25 |
# 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) ⇒ Object
33 34 35 36 37 38 |
# 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 |