Class: BlueShell::BufferedReaderExpector
- Inherits:
-
Object
- Object
- BlueShell::BufferedReaderExpector
- Defined in:
- lib/blue-shell/buffered_reader_expector.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #expect(pattern) ⇒ Object
-
#initialize(out, debug = false) ⇒ BufferedReaderExpector
constructor
A new instance of BufferedReaderExpector.
- #read_to_end ⇒ Object
Constructor Details
#initialize(out, debug = false) ⇒ BufferedReaderExpector
Returns a new instance of BufferedReaderExpector.
5 6 7 8 9 10 |
# File 'lib/blue-shell/buffered_reader_expector.rb', line 5 def initialize(out, debug = false) @out = out @debug = debug @unused = "" @output = "" end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
3 4 5 |
# File 'lib/blue-shell/buffered_reader_expector.rb', line 3 def output @output end |
Instance Method Details
#expect(pattern) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/blue-shell/buffered_reader_expector.rb', line 12 def expect(pattern) case pattern when String pattern = Regexp.new(Regexp.quote(pattern)) when Regexp else raise TypeError, "unsupported pattern class: #{pattern.class}" end result, buffer = read_pipe(BlueShell.timeout, pattern) @output << buffer result end |
#read_to_end ⇒ Object
28 29 30 31 |
# File 'lib/blue-shell/buffered_reader_expector.rb', line 28 def read_to_end _, buffer = read_pipe(0.01) @output << buffer end |