Class: Swaf
- Inherits:
-
Object
- Object
- Swaf
- Extended by:
- Forwardable
- Defined in:
- lib/swaf.rb,
lib/swaf/version.rb
Constant Summary collapse
- VERSION =
[ major = 0, minor = 1, patch = 0, ].join('.')
Instance Attribute Summary collapse
-
#dumper ⇒ Object
readonly
Returns the value of attribute dumper.
Class Method Summary collapse
Instance Method Summary collapse
- #detect(id) ⇒ Object (also: #find)
-
#initialize ⇒ Swaf
constructor
A new instance of Swaf.
- #load!(swf) ⇒ Object
- #replace(params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Swaf
Returns a new instance of Swaf.
29 30 31 32 |
# File 'lib/swaf.rb', line 29 def initialize @dumper = SwfRuby::SwfDumper.new @tamperer = SwfRuby::SwfTamperer.new end |
Instance Attribute Details
#dumper ⇒ Object (readonly)
Returns the value of attribute dumper.
24 25 26 |
# File 'lib/swaf.rb', line 24 def dumper @dumper end |
Class Method Details
.load(doc) ⇒ Object
12 13 14 15 |
# File 'lib/swaf.rb', line 12 def self.load(doc) (swaf = self.new).load!(doc) swaf end |
.load_file(filename) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/swaf.rb', line 17 def self.load_file(filename) (swaf = self.new).load!( File.binread(filename) ) swaf end |
Instance Method Details
#detect(id) ⇒ Object Also known as: find
38 39 40 41 42 |
# File 'lib/swaf.rb', line 38 def detect(id) if t = @dumper..each_with_index.find {|t, i| t.character_id == id } @dumper.[t[1]] end end |
#load!(swf) ⇒ Object
34 35 36 |
# File 'lib/swaf.rb', line 34 def load!(swf) self.dumper.dump(swf) end |
#replace(params = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/swaf.rb', line 45 def replace(params={}) self.class.load(@tamperer.replace(@dumper.swf, params.inject([]) {|targets, (k, v)| targets << make_target(k, v) })) end |