Class: IO

Inherits:
Object
  • Object
show all
Defined in:
wait/lib/nonblock.rb

Instance Method Summary collapse

Instance Method Details

#nonblock(nb = true) ⇒ Object



17
18
19
20
21
22
# File 'wait/lib/nonblock.rb', line 17

def nonblock(nb = true)
  nb, self.nonblock = nonblock?, nb
  yield
ensure
  self.nonblock = nb
end

#nonblock=(nb) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'wait/lib/nonblock.rb', line 7

def nonblock=(nb)
  f = fcntl(Fcntl::F_GETFL)
  if nb
    f |= File::NONBLOCK
  else
    f &= ~File::NONBLOCK
  end
  fcntl(Fcntl::F_SETFL, f)
end

#nonblock?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'wait/lib/nonblock.rb', line 3

def nonblock?
  (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) != 0
end

#ready?Boolean

=begin --- IO#ready? returns non-nil if input available without blocking, or nil. =end

Returns:

  • (Boolean)


55
56
57
# File 'wait/wait.c', line 55

static VALUE
io_ready_p(io)
VALUE io;

#waitObject

=begin --- IO#wait([timeout]) waits until input available or timed out and returns self, or nil when EOF reached. =end



81
82
83
# File 'wait/wait.c', line 81

static VALUE
io_wait(argc, argv, io)
int argc;