class XC

Attributes

device_types[R]
runtimes[R]

Public Class Methods

new() click to toggle source
# File lib/peach/xc.rb, line 4
def initialize
        @runtimes = init_runtimes
        @device_types = init_device_types
end

Public Instance Methods

device_name(identifier) click to toggle source
# File lib/peach/xc.rb, line 18
def device_name(identifier)
        return @device_types[identifier]
end
device_type_invalid(device_type) click to toggle source
# File lib/peach/xc.rb, line 26
def device_type_invalid(device_type)
        @device_types.select { |_, val| val == device_type }.empty?
end
exists(device:) click to toggle source
# File lib/peach/xc.rb, line 9
def exists(device:)
        return false unless device.udid
        Device.current_devices.include?(self)
end
init_device_types() click to toggle source
# File lib/peach/xc.rb, line 40
def init_device_types
        devicetypes_json = JSON.parse(load_device_types())
        devicetypes = devicetypes_json['devicetypes']
        devicetype_hash = {}
        devicetypes.each do |runtime|
                devicetype_hash[runtime["identifier"]] = runtime["name"]
        end
        devicetype_hash
end
init_runtimes() click to toggle source
# File lib/peach/xc.rb, line 30
def init_runtimes
        runtimes_json = JSON.parse(load_runtimes())
        runtimes = runtimes_json['runtimes']
        runtime_hash = {}
        runtimes.each do |runtime|
                runtime_hash[runtime["identifier"]] = runtime["name"]
        end
        runtime_hash
end
load_device_types() click to toggle source
# File lib/peach/xc.rb, line 54
def load_device_types
        `xcrun simctl list devicetypes -j`
end
load_runtimes() click to toggle source
# File lib/peach/xc.rb, line 50
def load_runtimes
        `xcrun simctl list runtimes -j`
end
runtime_invalid(runtime) click to toggle source
# File lib/peach/xc.rb, line 22
def runtime_invalid(runtime)
        @runtimes.select { |_, val| val == runtime }.empty?
end
runtime_name(identifier) click to toggle source
# File lib/peach/xc.rb, line 14
def runtime_name(identifier)
        return @runtimes[identifier]
end