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
- #device_type_invalid(device_type) ⇒ 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_invalid(runtime) ⇒ 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 |
#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_types ⇒ Object
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_runtimes ⇒ Object
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_types ⇒ Object
54 55 56 |
# File 'lib/peach/xc.rb', line 54 def load_device_types `xcrun simctl list devicetypes -j` end |
#load_runtimes ⇒ Object
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 |