class DeviceAPI::IOS::Device
Namespace for the Device
object.
Attributes
Public Class Methods
# File lib/device_api/ios/device.rb, line 16 def self.create options = {} self.new(options) end
# File lib/device_api/ios/device.rb, line 20 def initialize(options = {}) @qualifier = options[:qualifier] @serial = options[:serial] || options[:qualifier] @state = options[:state] end
Public Instance Methods
Return the device class - i.e. iPad, iPhone, etc @return (String) iOS device class
# File lib/device_api/ios/device.rb, line 56 def device_class get_prop('DeviceClass') end
Get the IMEI number of the device @return (String) IMEI number of current device
# File lib/device_api/ios/device.rb, line 68 def imei get_prop('InternationalMobileEquipmentIdentity') end
Install a specified IPA @param [String] ipa string containing path to the IPA to install @return [Boolean, Exception] true when the IPA installed successfully, otherwise an error is raised
# 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
Get the IP Address from the device @return [String] IP Address of current device
# File lib/device_api/ios/device.rb, line 80 def ip_address IPAddress.address(serial) end
# File lib/device_api/ios/device.rb, line 122 def list_installed_packages IDeviceInstaller.list_installed_packages(serial) end
Look up device model using the ios-devices gem - changing 'iPad4,7' to 'iPad mini 3' @return (String) human readable model and version (where applicable)
# File lib/device_api/ios/device.rb, line 44 def model Ios::Devices.search(get_prop('ProductType')).name end
Look up device name - i.e. Bob's iPhone @return (String) iOS device name
# File lib/device_api/ios/device.rb, line 38 def name IDeviceName.name(serial) end
Reboot the device
# File lib/device_api/ios/device.rb, line 127 def reboot restart end
# File lib/device_api/ios/device.rb, line 131 def restart IDeviceDiagnostics.restart(serial) end
Capture screenshot on device
# File lib/device_api/ios/device.rb, line 61 def screenshot(args = {}) args[:device_id] = serial IDeviceScreenshot.capture(args) end
Mapping of device status - used to provide a consistent status across platforms @return (String) common status string
# File lib/device_api/ios/device.rb, line 28 def status { 'device' => :ok, 'no device' => :dead, 'offline' => :offline }[@state] end
Has the 'Trust this device' dialog been accepted? @return (Boolean) true if the device is trusted, otherwise false
# File lib/device_api/ios/device.rb, line 74 def trusted? IDevice.trusted?(serial) end
Return whether or not the device is a tablet or mobile @return [Symbol] :tablet or :mobile depending on device_class
# File lib/device_api/ios/device.rb, line 114 def type if device_class.downcase == 'ipad' :tablet else :mobile end end
Uninstall a specified package @param [String] package_name string containing name of package to uninstall @return [Boolean, Exception] true when the package is uninstalled successfully, otherwise an error is raised
# 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
Returns the devices iOS version number - i.e. 8.2 @return (String) iOS version number
# File lib/device_api/ios/device.rb, line 50 def version get_prop('ProductVersion') end
Get the Wifi Mac address for the current device @return [String] Mac address of current device
# File lib/device_api/ios/device.rb, line 86 def wifi_mac_address get_prop('WiFiAddress') end
Private Instance Methods
# File lib/device_api/ios/device.rb, line 137 def get_prop(key) if !@props || !@props[key] @props = IDevice.get_props(serial) end @props[key] end
# File lib/device_api/ios/device.rb, line 144 def install_ipa(ipa) IDeviceInstaller.install_ipa(ipa: ipa, serial: serial) end
# File lib/device_api/ios/device.rb, line 148 def uninstall_package(package_name) IDeviceInstaller.uninstall_package(package: package_name, serial: serial) end