Module: SimCtl::Command::List

Included in:
SimCtl::Command
Defined in:
lib/simctl/command/list.rb

Instance Method Summary collapse

Instance Method Details

#device(filter) ⇒ SimCtl::Device?

Find a device

Parameters:

  • filter (Hash)

    the filter

Returns:



8
9
10
# File 'lib/simctl/command/list.rb', line 8

def device(filter)
  list_devices.where(filter).first
end

#devicetype(filter) ⇒ SimCtl::DeviceType

Find a device type

Parameters:

  • filter (Hash)

    the filter

Returns:

Raises:



17
18
19
20
# File 'lib/simctl/command/list.rb', line 17

def devicetype(filter)
  device_type = list_devicetypes.where(filter).first
  device_type || raise(DeviceTypeNotFound, "Could not find a device type matching #{filter.inspect}")
end

#list_devicesSimCtl::List

List all devices

Returns:



25
26
27
28
29
30
# File 'lib/simctl/command/list.rb', line 25

def list_devices
  Executor.execute(command_for('list', '-j', 'devices')) do |json|
    devices = json['devices'].map { |os, devs| devs.map { |device| Device.new(device.merge(os: os)) } }
    SimCtl::List.new(devices.flatten)
  end
end

#list_devicetypesSimCtl::List

List all device types

Returns:



35
36
37
38
39
# File 'lib/simctl/command/list.rb', line 35

def list_devicetypes
  Executor.execute(command_for('list', '-j', 'devicetypes')) do |json|
    SimCtl::List.new(json['devicetypes'].map { |devicetype| DeviceType.new(devicetype) })
  end
end

#list_runtimesSimCtl::List

List all runtimes

Returns:



44
45
46
47
48
# File 'lib/simctl/command/list.rb', line 44

def list_runtimes
  Executor.execute(command_for('list', '-j', 'runtimes')) do |json|
    SimCtl::List.new(json['runtimes'].map { |runtime| Runtime.new(runtime) })
  end
end

#runtime(filter) ⇒ SimCtl::Runtime

Find a runtime

Parameters:

  • filter (Hash)

    the filter

Returns:

Raises:



55
56
57
58
# File 'lib/simctl/command/list.rb', line 55

def runtime(filter)
  runtime = list_runtimes.where(filter).first
  runtime || raise(RuntimeNotFound, "Could not find a runtime matching #{filter.inspect}")
end