Class: Capybara::Flow::GifRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/flow/gif_recorder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_name) ⇒ GifRecorder

Returns a new instance of GifRecorder.



6
7
8
9
10
11
12
# File 'lib/capybara/flow/gif_recorder.rb', line 6

def initialize(output_name)
  @frame_dir = output_name
  @output_file = "#{output_name}.gif"
  make_path_unless_exists(output_file)
  make_path_unless_exists(@frame_dir)
  @gif_animator = GifAnimator.new(output_file, delay_in_ms: Capybara::Flow.configuration.delay_in_ms, iterations: Capybara::Flow.configuration.iterations)
end

Instance Attribute Details

#output_fileObject (readonly)

Returns the value of attribute output_file.



4
5
6
# File 'lib/capybara/flow/gif_recorder.rb', line 4

def output_file
  @output_file
end

Instance Method Details

#add(page) ⇒ Object



14
15
16
17
18
# File 'lib/capybara/flow/gif_recorder.rb', line 14

def add(page)
  file_name = File.join(@frame_dir, "#{current_frame}.png")
  page.save_screenshot(file_name, width: 320, height: 480)
  gif_animator.add(file_name)
end

#generate!Object



20
21
22
# File 'lib/capybara/flow/gif_recorder.rb', line 20

def generate!
  gif_animator.generate!
end