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



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)



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

def events
  @events
end

#fdInteger (readonly)



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



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



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

def pollin?
  @events & POLLIN != 0
end

#pollout?Boolean



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

def pollout?
  @events & POLLOUT != 0
end