Class: MTProto::TL::Contacts

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

Defined Under Namespace

Classes: Contact, User

Constant Summary collapse

SCHEMA_PATH =
File.expand_path('../../../../data/tl-schema.json', __dir__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contacts: [], saved_count: 0, users: [], not_modified: false) ⇒ Contacts

Returns a new instance of Contacts.



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

def initialize(contacts: [], saved_count: 0, users: [], not_modified: false)
  @contacts = contacts
  @saved_count = saved_count
  @users = users
  @not_modified = not_modified
end

Instance Attribute Details

#contactsObject (readonly)

Returns the value of attribute contacts.



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

def contacts
  @contacts
end

#not_modifiedObject (readonly)

Returns the value of attribute not_modified.



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

def not_modified
  @not_modified
end

#saved_countObject (readonly)

Returns the value of attribute saved_count.



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

def saved_count
  @saved_count
end

#usersObject (readonly)

Returns the value of attribute users.



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

def users
  @users
end

Class Method Details

.deserialize(data) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mtproto/tl/objects/contacts.rb', line 30

def self.deserialize(data)
  constructor = data[0, 4].unpack1('L<')
  return new(not_modified: true) if constructor == Constructors::CONTACTS_CONTACTS_NOT_MODIFIED
  raise UnexpectedConstructorError, constructor unless constructor == Constructors::CONTACTS_CONTACTS

  offset = 4
  contacts, offset = parse_contacts_vector(data, offset)
  saved_count = data[offset, 4].unpack1('l<')
  offset += 4
  users, = parse_users_vector(data, offset)

  new(contacts: contacts, saved_count: saved_count, users: users)
end

.schemaObject



26
27
28
# File 'lib/mtproto/tl/objects/contacts.rb', line 26

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

Instance Method Details

#not_modified?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mtproto/tl/objects/contacts.rb', line 22

def not_modified?
  @not_modified
end