Class: LIBUSB::Interface

Inherits:
FFI::Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/libusb/interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, *args) ⇒ Interface

Returns a new instance of Interface.



30
31
32
33
# File 'lib/libusb/interface.rb', line 30

def initialize(configuration, *args)
  @configuration = configuration
  super(*args)
end

Instance Attribute Details

#configurationConfiguration (readonly)

Returns the configuration this interface belongs to.

Returns:

  • (Configuration)

    the configuration this interface belongs to.



36
37
38
# File 'lib/libusb/interface.rb', line 36

def configuration
  @configuration
end

Instance Method Details

#<=>(o) ⇒ Object



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

def <=>(o)
  configuration<=>o.configuration
end

#alt_settingsObject Also known as: settings



38
39
40
41
42
43
44
# File 'lib/libusb/interface.rb', line 38

def alt_settings
  ifs = []
  self[:num_altsetting].times do |i|
    ifs << Setting.new(self, self[:altsetting] + i*Setting.size)
  end
  return ifs
end

#bInterfaceNumberObject

Number of this interface.



26
27
28
# File 'lib/libusb/interface.rb', line 26

def bInterfaceNumber
  settings.first.bInterfaceNumber
end

#deviceObject

The Device this Interface belongs to.



52
# File 'lib/libusb/interface.rb', line 52

def device() self.configuration.device end

#endpointsObject

Return all endpoints of all alternative settings as Array of Endpoints.



54
# File 'lib/libusb/interface.rb', line 54

def endpoints() self.alt_settings.map {|d| d.endpoints }.flatten end

#inspectObject



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

def inspect
  "\#<#{self.class} #{bInterfaceNumber}>"
end