Class: XC
- Inherits:
-
Object
- Object
- XC
- Defined in:
- lib/peach/xc.rb
Instance Attribute Summary collapse
-
#device_types ⇒ Object
readonly
Returns the value of attribute device_types.
-
#runtimes ⇒ Object
readonly
Returns the value of attribute runtimes.
Instance Method Summary collapse
- #device_name(identifier) ⇒ Object
- #exists(device:) ⇒ Object
- #init_device_types ⇒ Object
- #init_runtimes ⇒ Object
-
#initialize ⇒ XC
constructor
A new instance of XC.
- #load_device_types ⇒ Object
- #load_runtimes ⇒ Object
- #runtime_name(identifier) ⇒ Object
Constructor Details
#initialize ⇒ XC
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_types ⇒ Object (readonly)
Returns the value of attribute device_types.
2 3 4 |
# File 'lib/peach/xc.rb', line 2 def device_types @device_types end |
#runtimes ⇒ Object (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_types ⇒ Object
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_runtimes ⇒ Object
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_types ⇒ Object
46 47 48 |
# File 'lib/peach/xc.rb', line 46 def load_device_types `xcrun simctl list devicetypes -j` end |
#load_runtimes ⇒ Object
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 |