Class: MTProto::Type::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/type/config.rb

Constant Summary collapse

CONSTRUCTOR =
0xcc1a241e
CONSTRUCTOR_ALT =
0x3072cfa1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags:, date:, expires:, test_mode:, this_dc:, dc_options:) ⇒ Config

Returns a new instance of Config.



54
55
56
57
58
59
60
61
# File 'lib/mtproto/type/config.rb', line 54

def initialize(flags:, date:, expires:, test_mode:, this_dc:, dc_options:)
  @flags = flags
  @date = date
  @expires = expires
  @test_mode = test_mode
  @this_dc = this_dc
  @dc_options = dc_options
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def date
  @date
end

#dc_optionsObject (readonly)

Returns the value of attribute dc_options.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def dc_options
  @dc_options
end

#expiresObject (readonly)

Returns the value of attribute expires.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def expires
  @expires
end

#flagsObject (readonly)

Returns the value of attribute flags.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def flags
  @flags
end

#test_modeObject (readonly)

Returns the value of attribute test_mode.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def test_mode
  @test_mode
end

#this_dcObject (readonly)

Returns the value of attribute this_dc.



9
10
11
# File 'lib/mtproto/type/config.rb', line 9

def this_dc
  @this_dc
end

Class Method Details

.deserialize(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mtproto/type/config.rb', line 11

def self.deserialize(data)
  offset = 4

  flags = data[offset, 4].unpack1('L<')
  offset += 4

  date = data[offset, 4].unpack1('L<')
  offset += 4

  expires = data[offset, 4].unpack1('L<')
  offset += 4

  test_mode = (data[offset, 4].unpack1('L<') == 0x997275b5)
  offset += 4

  this_dc = data[offset, 4].unpack1('L<')
  offset += 4

  dc_options_constructor = data[offset, 4].unpack1('L<')
  offset += 4

  raise "Expected vector constructor 0x1cb5c415, got 0x#{dc_options_constructor.to_s(16)}" unless dc_options_constructor == 0x1cb5c415

  dc_options_count = data[offset, 4].unpack1('L<')
  offset += 4

  dc_options = []
  dc_options_count.times do
    dc_option, bytes_read = DcOption.deserialize_from(data[offset..])
    dc_options << dc_option
    offset += bytes_read
  end

  new(
    flags: flags,
    date: date,
    expires: expires,
    test_mode: test_mode,
    this_dc: this_dc,
    dc_options: dc_options
  )
end