Class: PhpUnserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-common/v5/PhpUnserializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PhpUnserializer

Returns a new instance of PhpUnserializer.



2
3
4
5
# File 'lib/ruby-common/v5/PhpUnserializer.rb', line 2

def initialize(data)
  @data = data
  @index = 0
end

Instance Method Details

#unserializeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby-common/v5/PhpUnserializer.rb', line 7

def unserialize
  type = @data[@index]
  @index += 2 

  case type
  when 'i' then parse_int
  when 'd' then parse_float
  when 'b' then parse_boolean
  when 's' then parse_string
  when 'a' then parse_array
  when 'O' then parse_object
  else
    raise ArgumentError, "Unsupported type: #{type}"
  end
end