Class: XC

Inherits:
Object
  • Object
show all
Defined in:
lib/peach/xc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXC

Returns a new instance of XC.



4
5
6
7
# File 'lib/peach/xc.rb', line 4

def initialize
  @runtimes = init_runtimes
  @device_types = init_device_types
end

Instance Attribute Details

#device_typesObject (readonly)

Returns the value of attribute device_types.



2
3
4
# File 'lib/peach/xc.rb', line 2

def device_types
  @device_types
end

#runtimesObject (readonly)

Returns the value of attribute runtimes.



2
3
4
# File 'lib/peach/xc.rb', line 2

def runtimes
  @runtimes
end

Instance Method Details

#device_name(identifier) ⇒ Object



18
19
20
# File 'lib/peach/xc.rb', line 18

def device_name(identifier)
  return @device_types[identifier]
end

#exists(device:) ⇒ Object



9
10
11
12
# File 'lib/peach/xc.rb', line 9

def exists(device:)
  return false unless device.udid
  Device.current_devices.include?(self)
end

#init_device_typesObject



32
33
34
35
36
37
38
39
40
# File 'lib/peach/xc.rb', line 32

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_runtimesObject



22
23
24
25
26
27
28
29
30
# File 'lib/peach/xc.rb', line 22

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_typesObject



46
47
48
# File 'lib/peach/xc.rb', line 46

def load_device_types
  `xcrun simctl list devicetypes -j`
end

#load_runtimesObject



42
43
44
# File 'lib/peach/xc.rb', line 42

def load_runtimes
  `xcrun simctl list runtimes -j`
end

#runtime_name(identifier) ⇒ Object



14
15
16
# File 'lib/peach/xc.rb', line 14

def runtime_name(identifier)
  return @runtimes[identifier]
end