Class: Thwomp::Renderers::SWF
- Inherits:
-
Object
- Object
- Thwomp::Renderers::SWF
- Includes:
- Helper
- Defined in:
- lib/thwomp/renderers/swf.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#frame_count ⇒ Object
readonly
Returns the value of attribute frame_count.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #executable ⇒ Object
- #frame(number) ⇒ Object
- #frame_batch ⇒ Object
- #frames ⇒ Object
-
#initialize(url, options = {}) ⇒ SWF
constructor
A new instance of SWF.
- #output_file(timestamp) ⇒ Object
Methods included from Helper
Constructor Details
#initialize(url, options = {}) ⇒ SWF
Returns a new instance of SWF.
14 15 16 17 18 19 |
# File 'lib/thwomp/renderers/swf.rb', line 14 def initialize(url, ={}) @filename = Downloader.new(url).filename @frame_count = .fetch(:frame_count) { 10 } @width = .fetch(:width) { 500 } @height = .fetch(:height) { 500 } end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/thwomp/renderers/swf.rb', line 12 def filename @filename end |
#frame_count ⇒ Object (readonly)
Returns the value of attribute frame_count.
12 13 14 |
# File 'lib/thwomp/renderers/swf.rb', line 12 def frame_count @frame_count end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
12 13 14 |
# File 'lib/thwomp/renderers/swf.rb', line 12 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
12 13 14 |
# File 'lib/thwomp/renderers/swf.rb', line 12 def width @width end |
Instance Method Details
#executable ⇒ Object
56 57 58 |
# File 'lib/thwomp/renderers/swf.rb', line 56 def executable Thwomp.gnash_path || "gnash-dump" end |
#frame(number) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/thwomp/renderers/swf.rb', line 34 def frame(number) = Time.now.to_i Command.exec( "#{executable} -s1 --screenshot=#{number}" \ " --screenshot-file=#{output_file()}" \ " -1 -r1 --timeout 200 #{filename} -j #{width}" \ " -k #{height} > /dev/null 2>&1" ) "#{Dir.tmpdir}/frame_#{}_#{number}.png" end |
#frame_batch ⇒ Object
47 48 49 50 |
# File 'lib/thwomp/renderers/swf.rb', line 47 def frame_batch batch = ['last'] + (0..frame_count).to_a.reverse batch.join(',') end |
#frames ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/thwomp/renderers/swf.rb', line 21 def frames = Time.now.to_i Command.exec( "#{executable} -s1 --screenshot=#{frame_batch}" \ " --screenshot-file=#{output_file()}" \ " -1 -r1 --timeout 200 #{filename} -j #{width}" \ " -k #{height} > /dev/null 2>&1" ) sort Dir.glob("#{Dir.tmpdir}/frame_#{}_*.png") end |
#output_file(timestamp) ⇒ Object
52 53 54 |
# File 'lib/thwomp/renderers/swf.rb', line 52 def output_file() "#{Dir.tmpdir}/frame_#{}_%f.png" end |