Class: MTProto::TL::Dialogs

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

Defined Under Namespace

Classes: Dialog

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dialogs:, chats:, users:, count: nil, message_dates: {}) ⇒ Dialogs

Returns a new instance of Dialogs.



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

def initialize(dialogs:, chats:, users:, count: nil, message_dates: {})
  @dialogs = dialogs
  @chats = chats
  @users = users
  @count = count
  @message_dates = message_dates
end

Instance Attribute Details

#chatsObject (readonly)

Returns the value of attribute chats.



13
14
15
# File 'lib/mtproto/tl/objects/dialogs.rb', line 13

def chats
  @chats
end

#countObject (readonly)

Returns the value of attribute count.



13
14
15
# File 'lib/mtproto/tl/objects/dialogs.rb', line 13

def count
  @count
end

#dialogsObject (readonly)

Returns the value of attribute dialogs.



13
14
15
# File 'lib/mtproto/tl/objects/dialogs.rb', line 13

def dialogs
  @dialogs
end

#message_datesObject (readonly)

Returns the value of attribute message_dates.



13
14
15
# File 'lib/mtproto/tl/objects/dialogs.rb', line 13

def message_dates
  @message_dates
end

#usersObject (readonly)

Returns the value of attribute users.



13
14
15
# File 'lib/mtproto/tl/objects/dialogs.rb', line 13

def users
  @users
end

Class Method Details

.deserialize(data) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mtproto/tl/objects/dialogs.rb', line 27

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

  unless [Constructors::MESSAGES_DIALOGS, Constructors::MESSAGES_DIALOGS_SLICE].include?(constructor)
    raise UnexpectedConstructorError, constructor
  end

  offset = 4

  count = nil
  if constructor == Constructors::MESSAGES_DIALOGS_SLICE
    count = data[offset, 4].unpack1('L<')
    offset += 4
  end

  dialogs, offset = parse_dialogs_vector(data, offset)
  message_dates, offset = parse_messages_vector(data, offset)
  chats, offset = Peers.chats_at(data, offset)
  users, = Peers.users_at(data, offset)

  new(dialogs: dialogs, chats: chats, users: users, count: count, message_dates: message_dates)
end

Instance Method Details

#slice?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mtproto/tl/objects/dialogs.rb', line 23

def slice?
  !@count.nil?
end