Class: AMF::Deserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/amf/deserializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Deserializer

Returns a new instance of Deserializer.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/amf/deserializer.rb', line 11

def initialize( data )
  if StringIO == data.class
    @data = data
  else
    @data = StringIO.new data
  end
  readHeaders
  readMessages

  resetReferences
  @data = nil
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/amf/deserializer.rb', line 9

def headers
  @headers
end

#messagesObject (readonly)

Returns the value of attribute messages.



9
10
11
# File 'lib/amf/deserializer.rb', line 9

def messages
  @messages
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'lib/amf/deserializer.rb', line 9

def version
  @version
end

Instance Method Details

#serializeObject



24
25
26
# File 'lib/amf/deserializer.rb', line 24

def serialize
  AMF::Serializer.new( headers, messages, version ).data
end

#to_hashObject

make this work a little bit more like a ruby object



29
30
31
32
33
34
35
# File 'lib/amf/deserializer.rb', line 29

def to_hash
  {
      'version' => self.version,
      'headers' => self.headers.map{ |h| h.to_hash },
      'messages' => self.messages.map{ |m| m.to_hash },
  }
end