Class: DeviceAPI::IOS::Device
- Inherits:
-
Device
- Object
- Device
- DeviceAPI::IOS::Device
- Defined in:
- lib/device_api/ios/device.rb
Overview
Namespace for the Device object.
Instance Method Summary collapse
-
#device_class ⇒ String
Return the device class - i.e.
-
#imei ⇒ String
Get the IMEI number of the device.
-
#initialize(options = {}) ⇒ Device
constructor
A new instance of Device.
-
#install(ipa) ⇒ Boolean, Exception
Install a specified IPA.
-
#ip_address ⇒ String
Get the IP Address from the device.
-
#model ⇒ String
Look up device model using the ios-devices gem - changing ‘iPad4,7’ to ‘iPad mini 3’.
-
#name ⇒ String
Look up device name - i.e.
-
#status ⇒ String
Mapping of device status - used to provide a consistent status across platforms.
-
#trusted? ⇒ Boolean
Has the ‘Trust this device’ dialog been accepted?.
-
#type ⇒ Symbol
Return whether or not the device is a tablet or mobile.
-
#uninstall(package_name) ⇒ Boolean, Exception
Uninstall a specified package.
-
#version ⇒ String
Returns the devices iOS version number - i.e.
-
#wifi_mac_address ⇒ String
Get the Wifi Mac address for the current device.
Constructor Details
#initialize(options = {}) ⇒ Device
Returns a new instance of Device.
13 14 15 16 |
# File 'lib/device_api/ios/device.rb', line 13 def initialize( = {}) @serial = [:serial] @state = [:state] end |
Instance Method Details
#device_class ⇒ String
Return the device class - i.e. iPad, iPhone, etc
48 49 50 |
# File 'lib/device_api/ios/device.rb', line 48 def device_class get_prop('DeviceClass') end |
#imei ⇒ String
Get the IMEI number of the device
54 55 56 |
# File 'lib/device_api/ios/device.rb', line 54 def imei get_prop('InternationalMobileEquipmentIdentity') end |
#install(ipa) ⇒ Boolean, Exception
Install a specified IPA
79 80 81 82 83 84 85 86 |
# File 'lib/device_api/ios/device.rb', line 79 def install(ipa) fail StandardError, 'No IPA or app specified.', caller if ipa.empty? res = install_ipa(ipa) fail StandardError, res, caller unless res true end |
#ip_address ⇒ String
Get the IP Address from the device
66 67 68 |
# File 'lib/device_api/ios/device.rb', line 66 def ip_address IPAddress.address(serial) end |
#model ⇒ String
Look up device model using the ios-devices gem - changing ‘iPad4,7’ to ‘iPad mini 3’
36 37 38 |
# File 'lib/device_api/ios/device.rb', line 36 def model Ios::Devices.search(get_prop('ProductType')).name end |
#name ⇒ String
Look up device name - i.e. Bob’s iPhone
30 31 32 |
# File 'lib/device_api/ios/device.rb', line 30 def name IDeviceName.name(serial) end |
#status ⇒ String
Mapping of device status - used to provide a consistent status across platforms
20 21 22 23 24 25 26 |
# File 'lib/device_api/ios/device.rb', line 20 def status { 'device' => :ok, 'no device' => :dead, 'offline' => :offline }[@state] end |
#trusted? ⇒ Boolean
Has the ‘Trust this device’ dialog been accepted?
60 61 62 |
# File 'lib/device_api/ios/device.rb', line 60 def trusted? IDevice.trusted?(serial) end |
#type ⇒ Symbol
Return whether or not the device is a tablet or mobile
100 101 102 103 104 105 106 |
# File 'lib/device_api/ios/device.rb', line 100 def type if device_class.downcase == 'ipad' :tablet else :mobile end end |
#uninstall(package_name) ⇒ Boolean, Exception
Uninstall a specified package
91 92 93 94 95 96 |
# File 'lib/device_api/ios/device.rb', line 91 def uninstall(package_name) res = uninstall_package(package_name) fail StandardError, res, caller unless res true end |
#version ⇒ String
Returns the devices iOS version number - i.e. 8.2
42 43 44 |
# File 'lib/device_api/ios/device.rb', line 42 def version get_prop('ProductVersion') end |
#wifi_mac_address ⇒ String
Get the Wifi Mac address for the current device
72 73 74 |
# File 'lib/device_api/ios/device.rb', line 72 def wifi_mac_address get_prop('WiFiAddress') end |