Class: AsciicastFramesFileUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/asciinema/asciicast_frames_file_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_writer = JsonFileWriter.new) ⇒ AsciicastFramesFileUpdater

Returns a new instance of AsciicastFramesFileUpdater.



5
6
7
# File 'lib/asciinema/asciicast_frames_file_updater.rb', line 5

def initialize(file_writer = JsonFileWriter.new)
  @file_writer = file_writer
end

Instance Method Details

#update(asciicast, outfile_location = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/asciinema/asciicast_frames_file_updater.rb', line 9

def update(asciicast, outfile_location=nil)
  file = outfile_location.present? ? File.new(outfile_location, 'w') : Tempfile.new('outfile')
  # file = File.new(new_outfile_location, 'w')

  asciicast.with_terminal do |terminal|
    film = Film.new(asciicast.stdout, terminal)
    file_writer.write_enumerable(file, film.frames)
  end
  asciicast.stdout_frames = file
end