Class: MTProto::TL::Object

Inherits:
Object
  • Object
show all
Extended by:
Binary
Defined in:
lib/mtproto/tl/object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Binary

b_u32, b_u64, u32_b, u64_b

Constructor Details

#initialize(constructor, payload) ⇒ Object

Returns a new instance of Object.



10
11
12
13
# File 'lib/mtproto/tl/object.rb', line 10

def initialize(constructor, payload)
  @constructor = constructor
  @payload = payload
end

Instance Attribute Details

#constructorObject (readonly)

Returns the value of attribute constructor.



8
9
10
# File 'lib/mtproto/tl/object.rb', line 8

def constructor
  @constructor
end

#payloadObject (readonly)

Returns the value of attribute payload.



8
9
10
# File 'lib/mtproto/tl/object.rb', line 8

def payload
  @payload
end

Class Method Details

.deserialize(message) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/mtproto/tl/object.rb', line 15

def self.deserialize(message)
  body = message.body
  constructor_id = b_u32(body[0, 4])
  constructor = ConstructorNames::NAMES.fetch(constructor_id)
  payload = body[4..]

  new(constructor, payload)
end