Module: EndOfLife::TerminalHelper
Instance Method Summary collapse
- #error_msg(message, label: "[ERROR]") ⇒ Object
- #new_spinner(message, options = {success_mark: paint.green("✔"), error_mark: paint.red("✖")}) ⇒ Object
- #paint ⇒ Object
- #table ⇒ Object
- #with_loading_spinner(message) ⇒ Object
Instance Method Details
#error_msg(message, label: "[ERROR]") ⇒ Object
7 8 9 10 11 |
# File 'lib/end_of_life/terminal_helper.rb', line 7 def error_msg(, label: "[ERROR]") label = paint.red("#{label} ") "#{label} #{}" end |
#new_spinner(message, options = {success_mark: paint.green("✔"), error_mark: paint.red("✖")}) ⇒ Object
32 33 34 |
# File 'lib/end_of_life/terminal_helper.rb', line 32 def new_spinner(, = {success_mark: paint.green("✔"), error_mark: paint.red("✖")}) TTY::Spinner.new("[:spinner] #{}", ) end |
#paint ⇒ Object
28 29 30 |
# File 'lib/end_of_life/terminal_helper.rb', line 28 def paint @paint ||= Pastel.new end |
#table ⇒ Object
24 25 26 |
# File 'lib/end_of_life/terminal_helper.rb', line 24 def table(...) TTY::Table.new(...).render(:unicode, padding: [0, 1]) end |
#with_loading_spinner(message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/end_of_life/terminal_helper.rb', line 13 def with_loading_spinner() result = nil new_spinner().run do |spinner| result = yield(spinner) spinner.success end result end |