Module: MacOS::Screen

Defined in:
lib/macos/screen.rb

Instance Method Summary collapse

Instance Method Details

#capture {|tempfile| ... } ⇒ Object

Yields:

  • (tempfile)

Yield Parameters:

  • tempfile (Tempfile)


5
6
7
8
9
10
11
12
# File 'lib/macos/screen.rb', line 5

def capture
  tempfile = Tempfile.new(['screenshot', '.png'])
  system("screencapture -o -x #{tempfile.path}")
  yield tempfile
ensure
  tempfile.close
  tempfile.unlink
end