Parent

Class/Module Index [+]

Quicksearch

NIO::Monitor

Monitors watch IO objects for specific events

Attributes

interests[R]
io[R]
readiness[RW]
selector[R]
value[RW]

Public Class Methods

new(io, interests, selector) click to toggle source

:nodoc

# File lib/nio/monitor.rb, line 8
def initialize(io, interests, selector)
  unless io.is_a?(IO)
    if IO.respond_to? :try_convert
      io = IO.try_convert(io)
    elsif io.respond_to? :to_io
      io = io.to_io
    end

    raise TypeError, "can't convert #{io.class} into IO" unless io.is_a? IO
  end

  @io, @interests, @selector = io, interests, selector
  @closed = false
end

Public Instance Methods

close(deregister = true) click to toggle source

Deactivate this monitor

# File lib/nio/monitor.rb, line 38
def close(deregister = true)
  @closed = true
  @selector.deregister(io) if deregister
end
closed?() click to toggle source

Is this monitor closed?

# File lib/nio/monitor.rb, line 35
def closed?; @closed; end
readable?() click to toggle source

Is the IO object readable?

# File lib/nio/monitor.rb, line 24
def readable?
  readiness == :r || readiness == :rw
end
writable?() click to toggle source

Is the IO object writable?

# File lib/nio/monitor.rb, line 29
def writable?
  readiness == :w || readiness == :rw
end
Also aliased as: writeable?
writeable?() click to toggle source
Alias for: writable?

[Validate]

Generated with the Darkfish Rdoc Generator 2.