Class: Capybara::Animate::GifRecorder
- Inherits:
-
Object
- Object
- Capybara::Animate::GifRecorder
- Defined in:
- lib/capybara/animate/gif_recorder.rb
Instance Attribute Summary collapse
-
#output_file ⇒ Object
readonly
Returns the value of attribute output_file.
Instance Method Summary collapse
- #add(page) ⇒ Object
- #generate! ⇒ Object
-
#initialize(output_name) ⇒ GifRecorder
constructor
A new instance of GifRecorder.
Constructor Details
#initialize(output_name) ⇒ GifRecorder
Returns a new instance of GifRecorder.
8 9 10 11 12 13 |
# File 'lib/capybara/animate/gif_recorder.rb', line 8 def initialize(output_name) @output_file = "#{output_name}.gif" make_path_unless_exists(output_file) @gif_anime = Gifanime.new(output_file, delay: 40) @tmpdir = Dir.mktmpdir end |
Instance Attribute Details
#output_file ⇒ Object (readonly)
Returns the value of attribute output_file.
6 7 8 |
# File 'lib/capybara/animate/gif_recorder.rb', line 6 def output_file @output_file end |
Instance Method Details
#add(page) ⇒ Object
15 16 17 18 19 |
# File 'lib/capybara/animate/gif_recorder.rb', line 15 def add(page) file = "#{tmpdir}/#{current_frame}.png" page.save_screenshot(file, width: 320, height: 480) gif_anime.add(file) end |
#generate! ⇒ Object
21 22 23 |
# File 'lib/capybara/animate/gif_recorder.rb', line 21 def generate! gif_anime.generate! end |