Class: FIS::UI
Overview
Class responsible for displaying different level information
Instance Method Summary collapse
- #debug(error, newline = nil) ⇒ Object
- #debug! ⇒ Object
- #error(message) ⇒ Object
- #format_link(title, url) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(prompt) ⇒ UI
constructor
A new instance of UI.
- #newline(num = 1) ⇒ Object
- #print_link(title, url) ⇒ Object
- #print_table(table, options = {}) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(prompt) ⇒ UI
Returns a new instance of UI.
12 13 14 15 16 |
# File 'lib/fis/ui.rb', line 12 def initialize(prompt) @prompt = prompt @debug = ENV['DEBUG'] @shell = Thor::Shell::Basic.new end |
Instance Method Details
#debug(error, newline = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/fis/ui.rb', line 34 def debug(error, newline = nil) return unless @debug = ["#{error.class}: #{error.}", *error.backtrace] @prompt.say(newline ? .join("\n") : ) end |
#debug! ⇒ Object
41 42 43 |
# File 'lib/fis/ui.rb', line 41 def debug! @debug = true end |
#error(message) ⇒ Object
30 31 32 |
# File 'lib/fis/ui.rb', line 30 def error() @prompt.error() end |
#format_link(title, url) ⇒ Object
53 54 55 |
# File 'lib/fis/ui.rb', line 53 def format_link(title, url) TTY::Link.link_to(title, url) end |
#info(message) ⇒ Object
22 23 24 |
# File 'lib/fis/ui.rb', line 22 def info() @prompt.say() end |
#newline(num = 1) ⇒ Object
18 19 20 |
# File 'lib/fis/ui.rb', line 18 def newline(num = 1) @prompt.say("\n" * num) end |
#print_link(title, url) ⇒ Object
49 50 51 |
# File 'lib/fis/ui.rb', line 49 def print_link(title, url) @prompt.say(format_link(title, url)) end |
#print_table(table, options = {}) ⇒ Object
45 46 47 |
# File 'lib/fis/ui.rb', line 45 def print_table(table, = {}) @shell.print_table(table, ) end |
#warn(message) ⇒ Object
26 27 28 |
# File 'lib/fis/ui.rb', line 26 def warn() @prompt.warn() end |