Class: RunLoop::Device
- Inherits:
-
Object
- Object
- RunLoop::Device
- Defined in:
- lib/run_loop/device.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#udid ⇒ Object
readonly
Returns the value of attribute udid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name, version, udid) ⇒ Device
constructor
A new instance of Device.
-
#instruction_set ⇒ String
Return the instruction set for this device.
-
#instruments_identifier(xcode_tools = RunLoop::XCTools.new) ⇒ String
Returns and instruments-ready device identifier that is a suitable value for DEVICE_TARGET environment variable.
-
#physical_device? ⇒ Boolean
Is this a physical device?.
-
#simulator? ⇒ Boolean
Is this a simulator?.
Constructor Details
#initialize(name, version, udid) ⇒ Device
Returns a new instance of Device.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/run_loop/device.rb', line 8 def initialize(name, version, udid) @name = name if version.is_a? String @version = RunLoop::Version.new version else @version = version end @udid = udid end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/run_loop/device.rb', line 4 def name @name end |
#udid ⇒ Object (readonly)
Returns the value of attribute udid.
6 7 8 |
# File 'lib/run_loop/device.rb', line 6 def udid @udid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/run_loop/device.rb', line 5 def version @version end |
Instance Method Details
#instruction_set ⇒ String
Finding the instruction set of a device requires a third-party tool like ideviceinfo. Example: ‘$ ideviceinfo -u 89b59 < snip > ab7ba –key ’CPUArchitecture’ => arm64`
Return the instruction set for this device.
Simulator The simulator instruction set will be i386 or x86_64 depending on the the (marketing) name of the device.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/run_loop/device.rb', line 66 def instruction_set if self.simulator? if ['iPhone 4s', 'iPhone 5', 'iPad 2', 'iPad Retina'].include?(self.name) 'i386' else 'x86_64' end else raise 'Finding the instruction set of a device requires a third-party tool like ideviceinfo' end end |
#instruments_identifier(xcode_tools = RunLoop::XCTools.new) ⇒ String
Returns and instruments-ready device identifier that is a suitable value for DEVICE_TARGET environment variable.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/run_loop/device.rb', line 26 def instruments_identifier(xcode_tools=RunLoop::XCTools.new) if physical_device? self.udid else unless xcode_tools.xcode_version_gte_6? raise "Expected Xcode >= 6, but found version #{xcode_tools.version} - cannot create an identifier" end if self.version == RunLoop::Version.new('7.0.3') version_part = self.version.to_s else version_part = "#{self.version.major}.#{self.version.minor}" end "#{self.name} (#{version_part} Simulator)" end end |
#physical_device? ⇒ Boolean
Is this a physical device?
44 45 46 |
# File 'lib/run_loop/device.rb', line 44 def physical_device? not self.udid[/[a-f0-9]{40}/, 0].nil? end |
#simulator? ⇒ Boolean
Is this a simulator?
50 51 52 |
# File 'lib/run_loop/device.rb', line 50 def simulator? not self.physical_device? end |