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

#device_type_invalid(device_type) ⇒ Object



26
27
28
# File 'lib/peach/xc.rb', line 26

def device_type_invalid(device_type)
	@device_types.select { |_, val| val == device_type }.empty?
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



40
41
42
43
44
45
46
47
48
# 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_runtimesObject



30
31
32
33
34
35
36
37
38
# 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_typesObject



54
55
56
# File 'lib/peach/xc.rb', line 54

def load_device_types
	`xcrun simctl list devicetypes -j`
end

#load_runtimesObject



50
51
52
# File 'lib/peach/xc.rb', line 50

def load_runtimes
	`xcrun simctl list runtimes -j`
end

#runtime_invalid(runtime) ⇒ Object



22
23
24
# File 'lib/peach/xc.rb', line 22

def runtime_invalid(runtime)
	@runtimes.select { |_, val| val == runtime }.empty?
end

#runtime_name(identifier) ⇒ Object



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

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