Class: MTProto::TL::UpdatesDifference

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/tl/objects/updates_difference.rb

Constant Summary collapse

SCHEMA_PATH =
File.expand_path('../../../../data/tl-schema.json', __dir__)
MESSAGE_CONSTRUCTOR =
Constructors::MESSAGE
MESSAGE_SERVICE =
0x7a800e0a
MESSAGE_EMPTY =
0x90a6ca84

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, date: nil, seq: nil, new_messages: [], pts: nil, state: nil) ⇒ UpdatesDifference

Returns a new instance of UpdatesDifference.



12
13
14
15
16
17
18
19
# File 'lib/mtproto/tl/objects/updates_difference.rb', line 12

def initialize(type:, date: nil, seq: nil, new_messages: [], pts: nil, state: nil)
  @type = type
  @date = date
  @seq = seq
  @new_messages = new_messages
  @pts = pts
  @state = state
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



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

def date
  @date
end

#new_messagesObject (readonly)

Returns the value of attribute new_messages.



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

def new_messages
  @new_messages
end

#ptsObject (readonly)

Returns the value of attribute pts.



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

def pts
  @pts
end

#seqObject (readonly)

Returns the value of attribute seq.



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

def seq
  @seq
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.deserialize(data) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mtproto/tl/objects/updates_difference.rb', line 25

def self.deserialize(data)
  constructor = data[0, 4].unpack1('L<')

  case constructor
  when Constructors::UPDATES_DIFFERENCE_EMPTY
    parse_empty(data)
  when Constructors::UPDATES_DIFFERENCE, Constructors::UPDATES_DIFFERENCE_SLICE
    parse_difference(data, constructor)
  when Constructors::UPDATES_DIFFERENCE_TOO_LONG
    new(type: :too_long, pts: data[4, 4].unpack1('L<'))
  else
    warn "Unknown Difference constructor: 0x#{constructor.to_s(16)}, treating as empty"
    new(type: :empty, date: Time.now.to_i, seq: 0)
  end
end

.schemaObject



21
22
23
# File 'lib/mtproto/tl/objects/updates_difference.rb', line 21

def self.schema
  @schema ||= Schema.new(SCHEMA_PATH)
end