module Net::SSH::Test::Extensions::IO::ClassMethods

Public Instance Methods

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

The testing version of 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 143
def select_for_test(readers=nil, writers=nil, errors=nil, wait=nil)
  return select_for_real(readers, writers, errors, wait) unless Net::SSH::Test::Extensions::IO.extension_enabled?
  ready_readers = Array(readers).select { |r| r.select_for_read? }
  ready_writers = Array(writers).select { |r| r.select_for_write? }
  ready_errors  = Array(errors).select  { |r| r.select_for_error? }

  if ready_readers.any? || ready_writers.any? || ready_errors.any?
    return [ready_readers, ready_writers, ready_errors]

  processed = 0
  Array(readers).each do |reader|
    processed += 1 if reader.idle!

  raise "no readers were ready for reading, and none had any incoming packets" if processed == 0 && wait != 0