Class: LIBUSB::Context::Pollfd
- Inherits:
-
Object
- Object
- LIBUSB::Context::Pollfd
- Includes:
- Comparable
- Defined in:
- lib/libusb/context.rb
Instance Attribute Summary collapse
-
#events ⇒ Integer
readonly
Event flags to poll for.
-
#fd ⇒ Integer
readonly
Numeric file descriptor.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(fd, events = 0) ⇒ Pollfd
constructor
A new instance of Pollfd.
- #inspect ⇒ Object
-
#io ⇒ IO
IO object bound to the file descriptor.
-
#pollin? ⇒ Boolean
True if the file descriptor has to be observed for incoming/readable data.
-
#pollout? ⇒ Boolean
True if the file descriptor has to be observed for outgoing/writeable data.
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
#events ⇒ Integer (readonly)
Returns Event flags to poll for.
44 45 46 |
# File 'lib/libusb/context.rb', line 44 def events @events end |
#fd ⇒ Integer (readonly)
Returns 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 |
#inspect ⇒ Object
56 57 58 |
# File 'lib/libusb/context.rb', line 56 def inspect "\#<#{self.class} fd:#{@fd}#{' POLLIN' if pollin?}#{' POLLOUT' if pollout?}>" end |
#io ⇒ IO
Returns 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.
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.
52 53 54 |
# File 'lib/libusb/context.rb', line 52 def pollout? @events & POLLOUT != 0 end |