Class: Thwomp::AnimationPreview
- Inherits:
-
Object
- Object
- Thwomp::AnimationPreview
- Defined in:
- lib/thwomp/animation_preview.rb
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
TODO: (optional) use Thumbnail class to make png’s from the rendered frames, instead of passing the frames directly to ‘convert’.
Instance Method Summary collapse
- #generate! ⇒ Object
-
#gif_data ⇒ Object
returns the gif binary data of generated animation.
-
#initialize(frames) ⇒ AnimationPreview
constructor
A new instance of AnimationPreview.
Constructor Details
#initialize(frames) ⇒ AnimationPreview
Returns a new instance of AnimationPreview.
11 12 13 |
# File 'lib/thwomp/animation_preview.rb', line 11 def initialize(frames) @frames = frames end |
Instance Attribute Details
#frames ⇒ Object (readonly)
TODO: (optional) use Thumbnail class to make png’s from the rendered frames, instead of passing the frames directly to ‘convert’
9 10 11 |
# File 'lib/thwomp/animation_preview.rb', line 9 def frames @frames end |
Instance Method Details
#generate! ⇒ Object
15 16 17 18 19 |
# File 'lib/thwomp/animation_preview.rb', line 15 def generate! filename = "#{Dir.tmpdir}/animation_#{Time.now.to_i}.gif" Command.exec("convert #{frames.join(' ')} #{filename}") filename end |
#gif_data ⇒ Object
returns the gif binary data of generated animation
22 23 24 |
# File 'lib/thwomp/animation_preview.rb', line 22 def gif_data File.open(generate!, 'rb') { |f| f.read } end |