Class Index [+]

Quicksearch

Net::SSH::Test::Extensions::IO

An extension to the built-in ::IO class. Simply redefines IO.select so that it can be scripted in Net::SSH unit tests.

Public Instance Methods

select_for_test(readers=nil, writers=nil, errors=nil, wait=nil) click to toggle source

The testing version of ::IO.select. Assumes that all readers, writers, and errors arrays are either nil, or contain only objects that mix in Net::SSH::Test::Extensions::BufferedIo.

     # File lib/net/ssh/test/extensions.rb, line 127
127:         def select_for_test(readers=nil, writers=nil, errors=nil, wait=nil)
128:           ready_readers = Array(readers).select { |r| r.select_for_read? }
129:           ready_writers = Array(writers).select { |r| r.select_for_write? }
130:           ready_errors  = Array(errors).select  { |r| r.select_for_error? }
131: 
132:           if ready_readers.any? || ready_writers.any? || ready_errors.any?
133:             return [ready_readers, ready_writers, ready_errors]
134:           end
135: 
136:           processed = 0
137:           Array(readers).each do |reader|
138:             processed += 1 if reader.idle!
139:           end
140: 
141:           raise "no readers were ready for reading, and none had any incoming packets" if processed == 0
142:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.