Class: SwfRuby::DoActionDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/swf_ruby/do_action_dumper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDoActionDumper

Returns a new instance of DoActionDumper.



10
11
12
13
# File 'lib/swf_ruby/do_action_dumper.rb', line 10

def initialize
  @actions = nil
  @actions_addresses = nil
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



7
8
9
# File 'lib/swf_ruby/do_action_dumper.rb', line 7

def actions
  @actions
end

#actions_addressesObject

Returns the value of attribute actions_addresses.



8
9
10
# File 'lib/swf_ruby/do_action_dumper.rb', line 8

def actions_addresses
  @actions_addresses
end

#tagObject

Returns the value of attribute tag.



6
7
8
# File 'lib/swf_ruby/do_action_dumper.rb', line 6

def tag
  @tag
end

Instance Method Details

#dump(tag) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/swf_ruby/do_action_dumper.rb', line 15

def dump(tag)
  @tag = tag
  @tag = @tag.force_encoding("ASCII-8BIT") if @tag.respond_to? :force_encoding
  record_header = @tag[0, 2].unpack("v").first
  t = Swf::Tag.new(@tag)
  # tag check
  raise NotDoActionTagError if t.code != 12
  # length check
  raise InvalidTagLengthError if t.length != @tag.length

  @actions = []
  @actions_addresses = []
  tags_index = (t.long_header) ? 6 : 2
  while tags_index < t.length
    @actions_addresses << tags_index
    ar = Swf::ActionRecord.new(@tag[tags_index..-1])
    tags_index += ar.length
    @actions << ar
  end
end