Class: SwfUtil::SWFDecompressor
- Inherits:
-
SWFCompression
- Object
- SWFCompression
- SwfUtil::SWFDecompressor
- Defined in:
- lib/swf_util/swf-decompressor.rb
Instance Method Summary collapse
-
#initialize(from = nil, to = nil) ⇒ SWFDecompressor
constructor
A new instance of SWFDecompressor.
- #read_file(file, to) ⇒ Object
- #uncompress(bytes) ⇒ Object
Methods inherited from SWFCompression
#read_full_size, #read_size, #strip
Constructor Details
#initialize(from = nil, to = nil) ⇒ SWFDecompressor
Returns a new instance of SWFDecompressor.
5 6 7 |
# File 'lib/swf_util/swf-decompressor.rb', line 5 def initialize(from=nil,to=nil) read_file(from,to) if !from.nil? and !to.nil? end |
Instance Method Details
#read_file(file, to) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/swf_util/swf-decompressor.rb', line 8 def read_file(file,to) swf=nil File.open(file,"r") do |f| swf=f.read(read_full_size(file)) end decomp=uncompress(swf) File.open(to,"w+") do |f| f.write(decomp) end end |
#uncompress(bytes) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/swf_util/swf-decompressor.rb', line 18 def uncompress(bytes) decompressor =Zlib::Inflate.new swf=decompressor.inflate(strip(bytes)) swf=bytes[0,8]+swf swf[0] = 70 swf end |