Class: RocketAMF::Pure::AMF3Deserializer

Inherits:
Object
  • Object
show all
Includes:
ReadIOHelpers
Defined in:
lib/rocketamf/pure/deserializer.rb

Overview

AMF3 implementation of deserializer, loaded automatically by the AMF0 deserializer when needed

Instance Method Summary collapse

Methods included from ReadIOHelpers

#byte_order, #byte_order_little?, #read_double, #read_int16_network, #read_int8, #read_word16_network, #read_word32_network, #read_word8

Constructor Details

#initializeAMF3Deserializer

Returns a new instance of AMF3Deserializer.



161
162
163
164
165
# File 'lib/rocketamf/pure/deserializer.rb', line 161

def initialize
  @string_cache = []
  @object_cache = []
  @trait_cache = []
end

Instance Method Details

#deserialize(source, type = nil) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/rocketamf/pure/deserializer.rb', line 167

def deserialize(source, type=nil)
  source = StringIO.new(source) unless StringIO === source
  type = read_int8 source unless type
  case type
  when AMF3_UNDEFINED_MARKER
    nil
  when AMF3_NULL_MARKER
    nil
  when AMF3_FALSE_MARKER
    false
  when AMF3_TRUE_MARKER
    true
  when AMF3_INTEGER_MARKER
    read_integer source
  when AMF3_DOUBLE_MARKER
    read_number source
  when AMF3_STRING_MARKER
    read_string source
  when AMF3_XML_DOC_MARKER, AMF3_XML_MARKER
    read_xml source
  when AMF3_DATE_MARKER
    read_date source
  when AMF3_ARRAY_MARKER
    read_array source
  when AMF3_OBJECT_MARKER
    read_object source
  when AMF3_BYTE_ARRAY_MARKER
    read_amf3_byte_array source
  when AMF3_DICT_MARKER
    read_dict source
  else
    raise AMFError, "Invalid type: #{type}"
  end
end