Module: SimCtl::Command::List
- Included in:
- SimCtl::Command
- Defined in:
- lib/simctl/command/list.rb
Instance Method Summary collapse
-
#device(filter) ⇒ SimCtl::Device?
Find a device.
-
#devicetype(filter) ⇒ SimCtl::DeviceType
Find a device type.
-
#list_devices ⇒ SimCtl::List
List all devices.
-
#list_devicetypes ⇒ SimCtl::List
List all device types.
-
#list_runtimes ⇒ SimCtl::List
List all runtimes.
-
#runtime(filter) ⇒ SimCtl::Runtime
Find a runtime.
Instance Method Details
#device(filter) ⇒ SimCtl::Device?
Find a device
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
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_devices ⇒ SimCtl::List
List all devices
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_devicetypes ⇒ SimCtl::List
List all device types
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_runtimes ⇒ SimCtl::List
List all runtimes
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
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 |