Class: IO
- Inherits:
-
Object
- Object
- IO
- Defined in:
- lib/expect/io.rb
Instance Method Summary collapse
- #_io_buf0 ⇒ Object
- #_io_buf1 ⇒ Object
- #_io_exit? ⇒ Boolean
- #_io_more? ⇒ Boolean
- #_io_read_char ⇒ Object
- #_io_save(no_echo = false, match_string = nil, ch = nil) ⇒ Object
- #_io_string ⇒ Object
- #_io_string! ⇒ Object
- #_io_sync ⇒ Object
- #readbuf(ti = 10) ⇒ Object
Instance Method Details
#_io_buf0 ⇒ Object
18 |
# File 'lib/expect/io.rb', line 18 def _io_buf0 ; @_buf0_ ; end |
#_io_buf1 ⇒ Object
19 |
# File 'lib/expect/io.rb', line 19 def _io_buf1 ; @_buf1_ ; end |
#_io_exit? ⇒ Boolean
17 |
# File 'lib/expect/io.rb', line 17 def _io_exit? ; _io_buf0.last.nil? ; end |
#_io_more? ⇒ Boolean
16 |
# File 'lib/expect/io.rb', line 16 def _io_more? ; ! IO.select([self],nil,nil,0.20).nil? ; end |
#_io_read_char ⇒ Object
32 33 34 35 36 37 |
# File 'lib/expect/io.rb', line 32 def _io_read_char c = getc @_buf0_ << c.chr unless c.nil? exp_internal "buf0: [#{_io_string.gsub(/\n/,'\n').gsub(/\r/,'\r')}]" c end |
#_io_save(no_echo = false, match_string = nil, ch = nil) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/expect/io.rb', line 8 def _io_save(no_echo=false, match_string=nil, ch=nil) s = _io_string! exp_internal match_string exp_internal s s = s.chomp(ch) if ch _io_buf1 << s _io_buf1 end |
#_io_string ⇒ Object
20 |
# File 'lib/expect/io.rb', line 20 def _io_string ; @_buf0_.join ; end |
#_io_string! ⇒ Object
21 22 23 24 25 |
# File 'lib/expect/io.rb', line 21 def _io_string! b = _io_string @_buf0_=[] b end |
#_io_sync ⇒ Object
26 27 28 29 30 31 |
# File 'lib/expect/io.rb', line 26 def _io_sync @_buf0_ ||=[] while _io_more? break if _io_read_char.nil? end end |
#readbuf(ti = 10) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/expect/io.rb', line 38 def readbuf(ti=10) @_buf0_, @_buf1_=[],[] loop do if IO.select([self],nil,nil,ti).nil? exp_internal "IO.select is NIL (TIMEOUT=#{ti})" @_buf0_ << nil else _io_read_char end yield(self) end end |