Class: Pressy::Console
- Inherits:
-
Object
- Object
- Pressy::Console
- Defined in:
- lib/pressy/console.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout, error: $stderr) ⇒ Console
constructor
A new instance of Console.
- #prompt(label, echo: true) ⇒ Object
- #run(*cmd) ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout, error: $stderr) ⇒ Console
Returns a new instance of Console
6 7 8 9 10 |
# File 'lib/pressy/console.rb', line 6 def initialize(input: $stdin, output: $stdout, error: $stderr) @input = input @output = output @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error
4 5 6 |
# File 'lib/pressy/console.rb', line 4 def error @error end |
#input ⇒ Object (readonly)
Returns the value of attribute input
4 5 6 |
# File 'lib/pressy/console.rb', line 4 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output
4 5 6 |
# File 'lib/pressy/console.rb', line 4 def output @output end |
Instance Method Details
#prompt(label, echo: true) ⇒ Object
12 13 14 15 16 |
# File 'lib/pressy/console.rb', line 12 def prompt(label, echo: true) error.print "#{label} " value = echo ? input.gets : input.noecho(&:gets) value.chomp end |
#run(*cmd) ⇒ Object
18 19 20 21 |
# File 'lib/pressy/console.rb', line 18 def run(*cmd) system(*cmd) $? end |