Class: AdbSdkLib::DeviceList

Inherits:
Hash
  • Object
show all
Defined in:
lib/adb-sdklib.rb

Overview

List of devices. It can be used as Enumerable like Set, and as Hash which key

is the serial number of the device.

Instance Method Summary collapse

Constructor Details

#initialize(devices = []) ⇒ DeviceList

Returns a new instance of DeviceList.

Parameters:

  • devices (Enumerable) (defaults to: [])

    Device object of Java



13
14
15
# File 'lib/adb-sdklib.rb', line 13

def initialize(devices = [])
  devices.each { |d| self[d.serial_number] = d }
end

Instance Method Details

#each {|device| ... } ⇒ Enumerator, self

Calls block once for each device in self, passing that device as a parameter. If no block is given, an enumerator is returned instead.

Yields:

  • (device)

    called with each device

Yield Parameters:

  • device (Device)

    a device instance

Returns:

  • (Enumerator)

    if not block given

  • (self)

    if block given



22
23
24
25
26
# File 'lib/adb-sdklib.rb', line 22

def each
  return self.values.each unless block_given?
  self.values.each {|device| yield device }
  return self
end