Class: GithubCLI::UI
- Inherits:
-
Object
- Object
- GithubCLI::UI
- Defined in:
- lib/github_cli/ui.rb
Overview
Class responsible for displaying different level information
Instance Attribute Summary collapse
-
#shell ⇒ Object
writeonly
Sets the attribute shell.
Instance Method Summary collapse
- #confirm(message, newline = nil) ⇒ Object
- #debug(error, newline = nil) ⇒ Object
- #debug! ⇒ Object
- #error(message, newline = nil) ⇒ Object
- #info(message, newline = nil) ⇒ Object
-
#initialize(shell) ⇒ UI
constructor
A new instance of UI.
- #print_table(table, options = {}) ⇒ Object
- #print_wrapped(message, options = {}) ⇒ Object
- #quite! ⇒ Object
- #terminal_width ⇒ Object
- #warn(message, newline = nil) ⇒ Object
Constructor Details
#initialize(shell) ⇒ UI
Returns a new instance of UI.
9 10 11 12 13 |
# File 'lib/github_cli/ui.rb', line 9 def initialize(shell) @shell = shell @quite = false @debug = ENV['DEBUG'] end |
Instance Attribute Details
#shell=(value) ⇒ Object (writeonly)
Sets the attribute shell
7 8 9 |
# File 'lib/github_cli/ui.rb', line 7 def shell=(value) @shell = value end |
Instance Method Details
#confirm(message, newline = nil) ⇒ Object
15 16 17 |
# File 'lib/github_cli/ui.rb', line 15 def confirm(, newline = nil) @shell.say , :green, newline end |
#debug(error, newline = nil) ⇒ Object
31 32 33 34 |
# File 'lib/github_cli/ui.rb', line 31 def debug(error, newline = nil) = ["#{error.class}: #{error.}", *error.backtrace] @shell.say .join("\n"), nil, newline end |
#debug! ⇒ Object
40 41 42 |
# File 'lib/github_cli/ui.rb', line 40 def debug! @debug = true end |
#error(message, newline = nil) ⇒ Object
27 28 29 |
# File 'lib/github_cli/ui.rb', line 27 def error(, newline = nil) @shell.say , :red, newline end |
#info(message, newline = nil) ⇒ Object
19 20 21 |
# File 'lib/github_cli/ui.rb', line 19 def info(, newline = nil) @shell.say , nil, newline end |
#print_table(table, options = {}) ⇒ Object
44 45 46 |
# File 'lib/github_cli/ui.rb', line 44 def print_table(table, = {}) @shell.print_table table, end |
#print_wrapped(message, options = {}) ⇒ Object
48 49 50 |
# File 'lib/github_cli/ui.rb', line 48 def print_wrapped(, = {}) @shell.print_wrapped , end |
#quite! ⇒ Object
36 37 38 |
# File 'lib/github_cli/ui.rb', line 36 def quite! @quite = true end |
#terminal_width ⇒ Object
52 53 54 |
# File 'lib/github_cli/ui.rb', line 52 def terminal_width @shell.terminal_width end |
#warn(message, newline = nil) ⇒ Object
23 24 25 |
# File 'lib/github_cli/ui.rb', line 23 def warn(, newline = nil) @shell.say , :yellow, newline end |