class AsciicastFramesFileUpdater

Attributes

file_writer[R]

Public Class Methods

new(file_writer = JsonFileWriter.new) click to toggle source
# File lib/asciinema/asciicast_frames_file_updater.rb, line 5
def initialize(file_writer = JsonFileWriter.new)
  @file_writer = file_writer
end

Public Instance Methods

update(asciicast, outfile_location=nil) click to toggle source
# 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