Sha256: b0fe016f455386e589ad08af68da5202e6667d9181e1959fd18563c1e77ed35c

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

require "rmagick"

module Capybara
  module Flow
    class GifAnimator
      attr_reader :frames, :delay, :iterations, :output_file

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

      def add(frame)
        frames << frame
      end

      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-flow-0.2.2 lib/capybara/flow/gif_animator.rb