Class: CapistranoSentinel::InputStream
- Defined in:
- lib/capistrano_sentinel/classes/input_stream.rb
Overview
class used to hook into the input stream
Instance Attribute Summary collapse
-
#actor ⇒ Object
Returns the value of attribute actor.
-
#real ⇒ Object
Returns the value of attribute real.
-
#stringio ⇒ Object
Returns the value of attribute stringio.
Class Method Summary collapse
Instance Method Summary collapse
- #finish ⇒ Object
- #gets(*_args) ⇒ Object
-
#initialize(real_stdin, actor, stringio) ⇒ InputStream
constructor
A new instance of InputStream.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(real_stdin, actor, stringio) ⇒ InputStream
Returns a new instance of InputStream.
15 16 17 18 19 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 15 def initialize(real_stdin, actor, stringio) self.real = real_stdin self.actor = actor self.stringio = stringio end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
30 31 32 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 30 def method_missing(name, *args, &block) @real.send name, *args, &block end |
Instance Attribute Details
#actor ⇒ Object
Returns the value of attribute actor.
13 14 15 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 13 def actor @actor end |
#real ⇒ Object
Returns the value of attribute real.
13 14 15 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 13 def real @real end |
#stringio ⇒ Object
Returns the value of attribute stringio.
13 14 15 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 13 def stringio @stringio end |
Class Method Details
.hook(actor, stringio) ⇒ Object
4 5 6 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 4 def self.hook(actor, stringio) $stdin = new($stdin, actor, stringio) end |
.unhook ⇒ Object
8 9 10 11 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 8 def self.unhook $stdin.finish if $stdin.is_a? CapistranoSentinel::InputStream $stdin = STDIN end |
Instance Method Details
#finish ⇒ Object
27 28 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 27 def finish end |
#gets(*_args) ⇒ Object
21 22 23 24 25 |
# File 'lib/capistrano_sentinel/classes/input_stream.rb', line 21 def gets(*_args) @stringio.rewind data = @stringio.read @actor.user_prompt_needed?(data) end |