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, selective: false, persistent: false, placeholder: nil) ⇒ ReplyKeyboardMarkup

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



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

def initialize(buttons:, resize: true, single_use: false,
               selective: false, persistent: false, placeholder: nil)
  @buttons = buttons
  @resize = resize
  @single_use = single_use
  @selective = selective
  @persistent = persistent
  @placeholder = placeholder
end

Instance Method Details

#serializeObject



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

def serialize
  flags = 0
  flags |= (1 << 0) if @resize
  flags |= (1 << 1) if @single_use
  flags |= (1 << 2) if @selective
  flags |= (1 << 3) if @placeholder
  flags |= (1 << 4) if @persistent

  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 += serialize_tl_string(@placeholder) if @placeholder
  result
end