Module: Vnehm::UI
- Defined in:
- lib/vnehm/ui.rb,
lib/vnehm/menu.rb
Defined Under Namespace
Classes: Menu
Constant Summary collapse
- SLEEP_PERIOD =
This constant used to set delay between user operation Because it’s more comfortable to have a small delay between interactions
0.7
Class Method Summary collapse
- .ask(arg = nil) ⇒ Object
- .error(msg) ⇒ Object
- .menu(&block) ⇒ Object
- .newline ⇒ Object
- .say(msg) ⇒ Object
- .sleep ⇒ Object
- .success(msg) ⇒ Object
- .term(msg = nil) ⇒ Object
- .warning(msg) ⇒ Object
Class Method Details
.ask(arg = nil) ⇒ Object
13 14 15 16 |
# File 'lib/vnehm/ui.rb', line 13 def self.ask(arg = nil) say arg if arg $stdin.gets.chomp end |
.error(msg) ⇒ Object
18 19 20 |
# File 'lib/vnehm/ui.rb', line 18 def self.error(msg) puts "#{msg}\n".red end |
.menu(&block) ⇒ Object
22 23 24 |
# File 'lib/vnehm/ui.rb', line 22 def self.(&block) Menu.new(&block) end |
.newline ⇒ Object
26 27 28 |
# File 'lib/vnehm/ui.rb', line 26 def self.newline puts end |
.say(msg) ⇒ Object
30 31 32 |
# File 'lib/vnehm/ui.rb', line 30 def self.say(msg) puts msg end |
.sleep ⇒ Object
34 35 36 |
# File 'lib/vnehm/ui.rb', line 34 def self.sleep Kernel.sleep(SLEEP_PERIOD) end |
.success(msg) ⇒ Object
38 39 40 |
# File 'lib/vnehm/ui.rb', line 38 def self.success(msg) puts msg.green end |
.term(msg = nil) ⇒ Object
42 43 44 45 |
# File 'lib/vnehm/ui.rb', line 42 def self.term(msg = nil) puts msg.red if msg raise VnehmExit end |
.warning(msg) ⇒ Object
47 48 49 |
# File 'lib/vnehm/ui.rb', line 47 def self.warning(msg) puts "#{msg}".yellow end |