Class: Usbmux::USBMux
- Inherits:
-
Object
- Object
- Usbmux::USBMux
- Defined in:
- lib/usbmux/usbmux.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
Returns the value of attribute devices.
-
#listener ⇒ Object
Returns the value of attribute listener.
-
#protocol_class ⇒ Object
Returns the value of attribute protocol_class.
-
#socket_path ⇒ Object
Returns the value of attribute socket_path.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #connect(device, port) ⇒ Object
-
#initialize(socket_path = nil) ⇒ USBMux
constructor
A new instance of USBMux.
- #process(timeout = nil) ⇒ Object
Constructor Details
#initialize(socket_path = nil) ⇒ USBMux
Returns a new instance of USBMux.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/usbmux/usbmux.rb', line 305 def initialize(socket_path = nil) if socket_path.nil? if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ socket_path = '/var/run/usbmuxd' else socket_path = '/var/run/usbmuxd' end end @socket_path = socket_path begin @protocol_class = BinaryProtocol @version = 0 @listener = MuxConnection.new(@socket_path, @protocol_class) @listener.listen() rescue MuxVersionError @protocol_class = PlistProtocol @version = 1 @listener = MuxConnection.new(@socket_path, @protocol_class) @listener.listen() end @devices = @listener.devices end |
Instance Attribute Details
#devices ⇒ Object
Returns the value of attribute devices.
304 305 306 |
# File 'lib/usbmux/usbmux.rb', line 304 def devices @devices end |
#listener ⇒ Object
Returns the value of attribute listener.
304 305 306 |
# File 'lib/usbmux/usbmux.rb', line 304 def listener @listener end |
#protocol_class ⇒ Object
Returns the value of attribute protocol_class.
304 305 306 |
# File 'lib/usbmux/usbmux.rb', line 304 def protocol_class @protocol_class end |
#socket_path ⇒ Object
Returns the value of attribute socket_path.
304 305 306 |
# File 'lib/usbmux/usbmux.rb', line 304 def socket_path @socket_path end |
#version ⇒ Object
Returns the value of attribute version.
304 305 306 |
# File 'lib/usbmux/usbmux.rb', line 304 def version @version end |
Instance Method Details
#connect(device, port) ⇒ Object
332 333 334 335 |
# File 'lib/usbmux/usbmux.rb', line 332 def connect(device, port) connection = MuxConnection.new(@socket_path, @protocol_class) connection.connect(device, port) end |
#process(timeout = nil) ⇒ Object
328 329 330 |
# File 'lib/usbmux/usbmux.rb', line 328 def process(timeout = nil) @listener.process(timeout) end |