Class: Strobe::CLI::Input
- Inherits:
-
Object
- Object
- Strobe::CLI::Input
- Defined in:
- lib/strobe/cli/input.rb
Defined Under Namespace
Classes: Menu
Instance Attribute Summary collapse
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #agree(msg = nil) ⇒ Object
- #ask(msg = nil) ⇒ Object
- #ask_for_password(msg = nil) ⇒ Object
- #choose {|m| ... } ⇒ Object
- #gets(*args) ⇒ Object
-
#initialize(stdin = STDIN, stdout = STDOUT) ⇒ Input
constructor
A new instance of Input.
- #print(*args) ⇒ Object
- #puts(*args) ⇒ Object
Constructor Details
#initialize(stdin = STDIN, stdout = STDOUT) ⇒ Input
Returns a new instance of Input.
47 48 49 |
# File 'lib/strobe/cli/input.rb', line 47 def initialize(stdin = STDIN, stdout = STDOUT) @stdin, @stdout = stdin, stdout end |
Instance Attribute Details
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
45 46 47 |
# File 'lib/strobe/cli/input.rb', line 45 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
45 46 47 |
# File 'lib/strobe/cli/input.rb', line 45 def stdout @stdout end |
Instance Method Details
#agree(msg = nil) ⇒ Object
56 57 58 59 60 |
# File 'lib/strobe/cli/input.rb', line 56 def agree(msg = nil) print msg if msg c = gets.strip.downcase c == "y" || c.strip.blank? end |
#ask(msg = nil) ⇒ Object
51 52 53 54 |
# File 'lib/strobe/cli/input.rb', line 51 def ask(msg = nil) print msg if msg gets.strip end |
#ask_for_password(msg = nil) ⇒ Object
68 69 70 71 |
# File 'lib/strobe/cli/input.rb', line 68 def ask_for_password(msg = nil) print msg if msg running_on_windows? ? ask_for_password_on_windows : ask_for_password_on_others end |
#choose {|m| ... } ⇒ Object
62 63 64 65 66 |
# File 'lib/strobe/cli/input.rb', line 62 def choose(&block) m = Menu.new(self) yield m m.ask end |
#gets(*args) ⇒ Object
81 82 83 |
# File 'lib/strobe/cli/input.rb', line 81 def gets(*args) stdin.gets(*args) end |
#print(*args) ⇒ Object
77 78 79 |
# File 'lib/strobe/cli/input.rb', line 77 def print(*args) stdout.print(*args) end |
#puts(*args) ⇒ Object
73 74 75 |
# File 'lib/strobe/cli/input.rb', line 73 def puts(*args) stdout.puts(*args) end |