Class: MTProto::Type::SentCode
- Inherits:
-
Object
- Object
- MTProto::Type::SentCode
- Defined in:
- lib/mtproto/type/sent_code.rb
Constant Summary collapse
- CONSTRUCTOR =
0x5e002502
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#next_type ⇒ Object
readonly
Returns the value of attribute next_type.
-
#phone_code_hash ⇒ Object
readonly
Returns the value of attribute phone_code_hash.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(flags:, type:, phone_code_hash:, next_type: nil, timeout: nil) ⇒ SentCode
constructor
A new instance of SentCode.
- #to_h ⇒ Object
Constructor Details
#initialize(flags:, type:, phone_code_hash:, next_type: nil, timeout: nil) ⇒ SentCode
Returns a new instance of SentCode.
48 49 50 51 52 53 54 |
# File 'lib/mtproto/type/sent_code.rb', line 48 def initialize(flags:, type:, phone_code_hash:, next_type: nil, timeout: nil) @flags = flags @type = type @phone_code_hash = phone_code_hash @next_type = next_type @timeout = timeout end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
8 9 10 |
# File 'lib/mtproto/type/sent_code.rb', line 8 def flags @flags end |
#next_type ⇒ Object (readonly)
Returns the value of attribute next_type.
8 9 10 |
# File 'lib/mtproto/type/sent_code.rb', line 8 def next_type @next_type end |
#phone_code_hash ⇒ Object (readonly)
Returns the value of attribute phone_code_hash.
8 9 10 |
# File 'lib/mtproto/type/sent_code.rb', line 8 def phone_code_hash @phone_code_hash end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/mtproto/type/sent_code.rb', line 8 def timeout @timeout end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/mtproto/type/sent_code.rb', line 8 def type @type end |
Class Method Details
.deserialize(data) ⇒ Object
10 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 |
# File 'lib/mtproto/type/sent_code.rb', line 10 def self.deserialize(data) offset = 4 flags = data[offset, 4].unpack1('L<') offset += 4 type, type_bytes_read = SentCodeType.deserialize_from(data[offset..]) offset += type_bytes_read phone_code_hash_length = data[offset].ord offset += 1 phone_code_hash = data[offset, phone_code_hash_length] offset += phone_code_hash_length padding = (4 - ((phone_code_hash_length + 1) % 4)) % 4 offset += padding next_type = nil if (flags & (1 << 1)) != 0 next_type, next_type_bytes_read = CodeType.deserialize_from(data[offset..]) offset += next_type_bytes_read end timeout = nil if (flags & (1 << 2)) != 0 timeout = data[offset, 4].unpack1('L<') end new( flags: flags, type: type, phone_code_hash: phone_code_hash, next_type: next_type, timeout: timeout ) end |
Instance Method Details
#to_h ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/mtproto/type/sent_code.rb', line 56 def to_h { phone_code_hash: @phone_code_hash, type: @type, next_type: @next_type, timeout: @timeout }.compact end |