Class: LIBUSB::Context::Pollfd

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/libusb/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fd, events = 0) ⇒ Pollfd

Returns a new instance of Pollfd.



24
25
26
# File 'lib/libusb/context.rb', line 24

def initialize(fd, events=0)
  @fd, @events = fd, events
end

Instance Attribute Details

#eventsInteger (readonly)

Returns Event flags to poll for.

Returns:

  • (Integer)

    Event flags to poll for



44
45
46
# File 'lib/libusb/context.rb', line 44

def events
  @events
end

#fdInteger (readonly)

Returns Numeric file descriptor.

Returns:

  • (Integer)

    Numeric file descriptor



41
42
43
# File 'lib/libusb/context.rb', line 41

def fd
  @fd
end

Instance Method Details

#<=>(other) ⇒ Object



28
29
30
# File 'lib/libusb/context.rb', line 28

def <=>(other)
  @fd <=> other.fd
end

#inspectObject



56
57
58
# File 'lib/libusb/context.rb', line 56

def inspect
  "\#<#{self.class} fd:#{@fd}#{' POLLIN' if pollin?}#{' POLLOUT' if pollout?}>"
end

#ioIO

Returns IO object bound to the file descriptor.

Returns:

  • (IO)

    IO object bound to the file descriptor.



33
34
35
36
37
38
# File 'lib/libusb/context.rb', line 33

def io
  rio = IO.new @fd
  # autoclose is available in Ruby-1.9+ only
  rio.autoclose = false if rio.respond_to?( :autoclose= )
  rio
end

#pollin?Boolean

Returns True if the file descriptor has to be observed for incoming/readable data.

Returns:

  • (Boolean)

    True if the file descriptor has to be observed for incoming/readable data



47
48
49
# File 'lib/libusb/context.rb', line 47

def pollin?
  @events & POLLIN != 0
end

#pollout?Boolean

Returns True if the file descriptor has to be observed for outgoing/writeable data.

Returns:

  • (Boolean)

    True if the file descriptor has to be observed for outgoing/writeable data



52
53
54
# File 'lib/libusb/context.rb', line 52

def pollout?
  @events & POLLOUT != 0
end