Class: VirtualBox::GuestControl::UsbDevice
- Inherits:
-
Object
- Object
- VirtualBox::GuestControl::UsbDevice
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/virtualbox/guest_control/usb_device.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#current_state ⇒ Object
Returns the value of attribute current_state.
-
#manufacturer ⇒ Object
Returns the value of attribute manufacturer.
-
#port ⇒ Object
Returns the value of attribute port.
-
#product ⇒ Object
Returns the value of attribute product.
-
#product_id ⇒ Object
Returns the value of attribute product_id.
-
#revision ⇒ Object
Returns the value of attribute revision.
-
#serial_number ⇒ Object
Returns the value of attribute serial_number.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#vbox_manage ⇒ Object
Returns the value of attribute vbox_manage.
-
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uuid) ⇒ UsbDevice
constructor
A new instance of UsbDevice.
- #state ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(uuid) ⇒ UsbDevice
Returns a new instance of UsbDevice.
46 47 48 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 46 def initialize(uuid) self.uuid = uuid end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
42 43 44 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 42 def address @address end |
#current_state ⇒ Object
Returns the value of attribute current_state.
42 43 44 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 42 def current_state @current_state end |
#manufacturer ⇒ Object
Returns the value of attribute manufacturer.
42 43 44 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 42 def manufacturer @manufacturer end |
#port ⇒ Object
Returns the value of attribute port.
42 43 44 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 42 def port @port end |
#product ⇒ Object
Returns the value of attribute product.
42 43 44 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 42 def product @product end |
#product_id ⇒ Object
Returns the value of attribute product_id.
41 42 43 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 41 def product_id @product_id end |
#revision ⇒ Object
Returns the value of attribute revision.
41 42 43 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 41 def revision @revision end |
#serial_number ⇒ Object
Returns the value of attribute serial_number.
43 44 45 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 43 def serial_number @serial_number end |
#uuid ⇒ Object
Returns the value of attribute uuid.
41 42 43 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 41 def uuid @uuid end |
#vbox_manage ⇒ Object
Returns the value of attribute vbox_manage.
44 45 46 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 44 def vbox_manage @vbox_manage end |
#vendor_id ⇒ Object
Returns the value of attribute vendor_id.
41 42 43 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 41 def vendor_id @vendor_id end |
Class Method Details
.all(vbox_manage) ⇒ Object
7 8 9 10 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 7 def all(vbox_manage) result = Shellter.run!(vbox_manage, "list", "usbhost") parse(result.stdout) end |
.parse(output) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 12 def parse(output) [].tap do |devices| device = nil output.lines.each do |line| if device if line.strip.blank? devices << device device = nil else key, value = line.split(":") key = key.strip.gsub(" ", "_").underscore value = value.strip begin device.send(:"#{key}=", value) rescue # this is the version/speed attribute... maybe we should parse it #puts [key, value].join(" => ") end end else next unless line =~ /UUID:/ value = line.split(":").last.strip device = new(value) end end end end |
Instance Method Details
#state ⇒ Object
54 55 56 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 54 def state current_state end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/virtualbox/guest_control/usb_device.rb', line 50 def to_s "#{product} (#{uuid}): #{current_state}" end |