Class: Gifanime

Inherits:
Object
  • Object
show all
Defined in:
lib/gifanime.rb,
lib/gifanime/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outputfile, options = {}) ⇒ Gifanime

Returns a new instance of Gifanime.



5
6
7
8
9
10
11
12
13
# File 'lib/gifanime.rb', line 5

def initialize(outputfile, options = {})
  @delay             = options[:delay]
  @iterations        = options[:iterations]
  @scene             = options[:scene]
  @ticks_per_secound = options[:ticks_per_secound]
  outputfile = outputfile + ".gif" unless outputfile =~ /\.gif\z/
  @outputfile        = outputfile
  @frames = []
end

Instance Attribute Details

#delayObject

Returns the value of attribute delay.



3
4
5
# File 'lib/gifanime.rb', line 3

def delay
  @delay
end

#framesObject

Returns the value of attribute frames.



3
4
5
# File 'lib/gifanime.rb', line 3

def frames
  @frames
end

#iterationsObject

Returns the value of attribute iterations.



3
4
5
# File 'lib/gifanime.rb', line 3

def iterations
  @iterations
end

#outputfileObject

Returns the value of attribute outputfile.



3
4
5
# File 'lib/gifanime.rb', line 3

def outputfile
  @outputfile
end

#sceneObject

Returns the value of attribute scene.



3
4
5
# File 'lib/gifanime.rb', line 3

def scene
  @scene
end

#ticks_per_secoundObject

Returns the value of attribute ticks_per_secound.



3
4
5
# File 'lib/gifanime.rb', line 3

def ticks_per_secound
  @ticks_per_secound
end

Instance Method Details

#add(frame) ⇒ Object



15
16
17
# File 'lib/gifanime.rb', line 15

def add(frame)
  frames << frame
end

#generate!Object



19
20
21
22
23
24
25
26
# File 'lib/gifanime.rb', line 19

def generate!
  gif = ::Magick::ImageList.new(*frames)
  gif.delay = delay if delay
  gif.iterations = iterations if iterations
  gif.scene = scene if scene
  gif.ticks_per_secound = ticks_per_secound if ticks_per_secound
  gif.write(outputfile)
end