class Nakal::Ios::Screen

Private Instance Methods

capture() click to toggle source
# File lib/nakal/ios/screen.rb, line 24
def capture
  `#{capture_script}`
  sleep 1
  Dir.glob(File.expand_path("~/Desktop/#{simulator_app_name}\\ Screen\\ Shot - Apple\\ Watch*")).each { |f| FileUtils.rm(f) }
  latest_file = Dir.glob(File.expand_path("~/Desktop/#{simulator_app_name}\\ Screen\\ Shot*")).max_by { |f| File.mtime(f) }
  File.rename(latest_file, "#{Nakal.image_location}/#{@name}.png")
end
capture_script() click to toggle source
# File lib/nakal/ios/screen.rb, line 7
def capture_script
  "osascript <<EOF
  tell application \"#{simulator_app_name}\"
  activate
  delay 0.5
  tell application \"System Events\" to keystroke \"1\" using {command down}
  delay 0.5
  tell application \"System Events\" to keystroke \"s\" using {command down}
  end tell
  EOF"
end
simulator_app_name() click to toggle source
# File lib/nakal/ios/screen.rb, line 19
def simulator_app_name
  xcode_7 = !(%x(instruments -s devices ; echo)).match(' Simulator\)')
  xcode_7 ? "Simulator" : "iOS Simulator"
end