Class: SimulatorRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/capa/simulator_recorder.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename: '') ⇒ SimulatorRecorder

Returns a new instance of SimulatorRecorder.



4
5
6
7
# File 'lib/capa/simulator_recorder.rb', line 4

def initialize(filename: '')
  abort('Please provide a name for the video') if filename.blank?
  @filename = filename
end

Instance Method Details

#recordObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/capa/simulator_recorder.rb', line 9

def record
  abort unless can_record?

  Signal.trap("SIGINT") { raise Capa::UserAbort }
  Signal.trap("SIGTSTP") { raise Capa::UserAbort }

  Thread.new do
    `xcrun simctl io booted recordVideo #{@filename}`
  end

  puts 'Capturing video... Press ENTER to save'
  p = gets.chomp
  `killall -SIGINT simctl`
end