Class: Disloku::CliAdapter
- Inherits:
-
Object
- Object
- Disloku::CliAdapter
- Defined in:
- lib/disloku/CliAdapter.rb
Constant Summary collapse
- @@in =
$stdin
- @@out =
$stdout
- @@rainbow =
Rainbow.new()
- @@default =
:none
Class Method Summary collapse
- .print(output = nil) ⇒ Object
- .puts(output = nil) ⇒ Object
- .queryYesNo(question, highPrio = false) ⇒ Object
- .queryYesNo!(question, highPrio = false) ⇒ Object
- .setYesNoBehavior(default) ⇒ Object
Class Method Details
.print(output = nil) ⇒ Object
44 45 46 |
# File 'lib/disloku/CliAdapter.rb', line 44 def print(output = nil) @@out.print(output) end |
.puts(output = nil) ⇒ Object
40 41 42 |
# File 'lib/disloku/CliAdapter.rb', line 40 def puts(output = nil) @@out.puts(output) end |
.queryYesNo(question, highPrio = false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/disloku/CliAdapter.rb', line 20 def queryYesNo(question, highPrio = false) color = highPrio ? :yellow : :green @@out.puts() @@out.puts(@@rainbow.wrap("#{question} (Y/N)?").color(color)) if ((@@default == :veryYes) || (@@default == :yes && !highPrio)) self.puts("Assuming 'yes'") return true else char = @@in.getch() return !char.match(/^[Yy]/).nil? end end |
.queryYesNo!(question, highPrio = false) ⇒ Object
34 35 36 37 38 |
# File 'lib/disloku/CliAdapter.rb', line 34 def queryYesNo!(question, highPrio = false) if (queryYesNo(question, highPrio)) yield end end |
.setYesNoBehavior(default) ⇒ Object
16 17 18 |
# File 'lib/disloku/CliAdapter.rb', line 16 def setYesNoBehavior(default) @@default = default end |