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 Attribute Summary collapse
-
#qualifier ⇒ Object
Returns the value of attribute qualifier.
Class Method Summary collapse
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.
- #list_installed_packages ⇒ Object
-
#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.
-
#reboot ⇒ Object
Reboot the device.
- #restart ⇒ Object
-
#screenshot(args = {}) ⇒ Object
Capture screenshot on device.
-
#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.
20 21 22 23 24 |
# File 'lib/device_api/ios/device.rb', line 20 def initialize( = {}) @qualifier = [:qualifier] @serial = [:serial] || [:qualifier] @state = [:state] end |
Instance Attribute Details
#qualifier ⇒ Object
Returns the value of attribute qualifier.
15 16 17 |
# File 'lib/device_api/ios/device.rb', line 15 def qualifier @qualifier end |
Class Method Details
.create(options = {}) ⇒ Object
16 17 18 |
# File 'lib/device_api/ios/device.rb', line 16 def self.create = {} self.new() end |
Instance Method Details
#device_class ⇒ String
Return the device class - i.e. iPad, iPhone, etc
56 57 58 |
# File 'lib/device_api/ios/device.rb', line 56 def device_class get_prop('DeviceClass') end |
#imei ⇒ String
Get the IMEI number of the device
68 69 70 |
# File 'lib/device_api/ios/device.rb', line 68 def imei get_prop('InternationalMobileEquipmentIdentity') end |
#install(ipa) ⇒ Boolean, Exception
Install a specified IPA
93 94 95 96 97 98 99 100 |
# File 'lib/device_api/ios/device.rb', line 93 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
80 81 82 |
# File 'lib/device_api/ios/device.rb', line 80 def ip_address IPAddress.address(serial) end |
#list_installed_packages ⇒ Object
122 123 124 |
# File 'lib/device_api/ios/device.rb', line 122 def list_installed_packages IDeviceInstaller.list_installed_packages(serial) end |
#model ⇒ String
Look up device model using the ios-devices gem - changing ‘iPad4,7’ to ‘iPad mini 3’
44 45 46 |
# File 'lib/device_api/ios/device.rb', line 44 def model Ios::Devices.search(get_prop('ProductType')).name end |
#name ⇒ String
Look up device name - i.e. Bob’s iPhone
38 39 40 |
# File 'lib/device_api/ios/device.rb', line 38 def name IDeviceName.name(serial) end |
#reboot ⇒ Object
Reboot the device
127 128 129 |
# File 'lib/device_api/ios/device.rb', line 127 def reboot restart end |
#restart ⇒ Object
131 132 133 |
# File 'lib/device_api/ios/device.rb', line 131 def restart IDeviceDiagnostics.restart(serial) end |
#screenshot(args = {}) ⇒ Object
Capture screenshot on device
61 62 63 64 |
# File 'lib/device_api/ios/device.rb', line 61 def screenshot(args = {}) args[:device_id] = serial IDeviceScreenshot.capture(args) end |
#status ⇒ String
Mapping of device status - used to provide a consistent status across platforms
28 29 30 31 32 33 34 |
# File 'lib/device_api/ios/device.rb', line 28 def status { 'device' => :ok, 'no device' => :dead, 'offline' => :offline }[@state] end |
#trusted? ⇒ Boolean
Has the ‘Trust this device’ dialog been accepted?
74 75 76 |
# File 'lib/device_api/ios/device.rb', line 74 def trusted? IDevice.trusted?(serial) end |
#type ⇒ Symbol
Return whether or not the device is a tablet or mobile
114 115 116 117 118 119 120 |
# File 'lib/device_api/ios/device.rb', line 114 def type if device_class.downcase == 'ipad' :tablet else :mobile end end |
#uninstall(package_name) ⇒ Boolean, Exception
Uninstall a specified package
105 106 107 108 109 110 |
# File 'lib/device_api/ios/device.rb', line 105 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
50 51 52 |
# File 'lib/device_api/ios/device.rb', line 50 def version get_prop('ProductVersion') end |
#wifi_mac_address ⇒ String
Get the Wifi Mac address for the current device
86 87 88 |
# File 'lib/device_api/ios/device.rb', line 86 def wifi_mac_address get_prop('WiFiAddress') end |