lib/simctl/device.rb in simctl-1.0.2 vs lib/simctl/device.rb in simctl-1.1.0

- old
+ new

@@ -1,22 +1,20 @@ require 'simctl/object' +require 'timeout' module SimCtl class Device < Object attr_reader :availability, :name, :os, :state, :udid - # Boot the device def boot! SimCtl.boot_device(self) end - # Delete the device def delete! SimCtl.delete_device(self) end - # Erase the device def erase! SimCtl.erase_device(self) end def kill! @@ -25,11 +23,22 @@ def launch! SimCtl.launch_device(self) end - # Shutdown the device def shutdown! SimCtl.shutdown_device(self) + end + + def state + @state.downcase.to_sym + end + + def wait!(timeout=15) + Timeout::timeout(timeout) do + loop do + break if yield SimCtl.device(udid: udid) + end + end end end end