Class: Capybara::Flow::GifAnimator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_file, options = {}) ⇒ GifAnimator



8
9
10
11
12
13
# File 'lib/capybara/flow/gif_animator.rb', line 8

def initialize(output_file, options = {})
  @delay = options[:delay_in_ms]
  @iterations = options[:iterations]
  @output_file = output_file
  @frames = []
end

Instance Attribute Details

#delayObject (readonly)

Returns the value of attribute delay.



6
7
8
# File 'lib/capybara/flow/gif_animator.rb', line 6

def delay
  @delay
end

#framesObject (readonly)

Returns the value of attribute frames.



6
7
8
# File 'lib/capybara/flow/gif_animator.rb', line 6

def frames
  @frames
end

#iterationsObject (readonly)

Returns the value of attribute iterations.



6
7
8
# File 'lib/capybara/flow/gif_animator.rb', line 6

def iterations
  @iterations
end

#output_fileObject (readonly)

Returns the value of attribute output_file.



6
7
8
# File 'lib/capybara/flow/gif_animator.rb', line 6

def output_file
  @output_file
end

Instance Method Details

#add(frame) ⇒ Object



15
16
17
# File 'lib/capybara/flow/gif_animator.rb', line 15

def add(frame)
  frames << frame
end

#generate!Object



19
20
21
22
23
24
25
# File 'lib/capybara/flow/gif_animator.rb', line 19

def generate!
  gif = ::Magick::ImageList.new(*frames)
  gif.delay = delay if delay
  gif.iterations = iterations if iterations
  gif.ticks_per_second = 1000
  gif.write(output_file)
end