Class: GithubCLI::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/github_cli/ui.rb

Overview

Class responsible for displaying different level information

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute shell to.


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(message, newline = nil)
  @shell.say message, :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)
  message = ["#{error.class}: #{error.message}", *error.backtrace]
  @shell.say message.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(message, newline = nil)
  @shell.say message, :red, newline
end

#info(message, newline = nil) ⇒ Object


19
20
21
# File 'lib/github_cli/ui.rb', line 19

def info(message, newline = nil)
  @shell.say message, nil, newline
end

44
45
46
# File 'lib/github_cli/ui.rb', line 44

def print_table(table, options = {})
  @shell.print_table table, options
end

48
49
50
# File 'lib/github_cli/ui.rb', line 48

def print_wrapped(message, options = {})
  @shell.print_wrapped message, options
end

#quite!Object


36
37
38
# File 'lib/github_cli/ui.rb', line 36

def quite!
  @quite = true
end

#terminal_widthObject


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(message, newline = nil)
  @shell.say message, :yellow, newline
end