Class: MTProto::TL::ReplyKeyboardMarkup

Inherits:
Object
  • Object
show all
Includes:
Binary
Defined in:
lib/mtproto/tl/objects/reply_keyboard_markup.rb

Constant Summary collapse

CONSTRUCTOR =
0x85dd99d1
KEYBOARD_BUTTON_ROW =
0x77608b83

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(buttons:, resize: true, single_use: false) ⇒ ReplyKeyboardMarkup

buttons: a single row of button objects (each responds to #serialize)



12
13
14
15
16
# File 'lib/mtproto/tl/objects/reply_keyboard_markup.rb', line 12

def initialize(buttons:, resize: true, single_use: false)
  @buttons = buttons
  @resize = resize
  @single_use = single_use
end

Instance Method Details

#serializeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mtproto/tl/objects/reply_keyboard_markup.rb', line 18

def serialize
  flags = 0
  flags |= (1 << 0) if @resize
  flags |= (1 << 1) if @single_use

  result = u32_b(CONSTRUCTOR)
  result += u32_b(flags)
  result += u32_b(Constructors::VECTOR)
  result += u32_b(1)
  result += u32_b(KEYBOARD_BUTTON_ROW)
  result += u32_b(Constructors::VECTOR)
  result += u32_b(@buttons.size)
  @buttons.each { |button| result += button.serialize }
  result
end