Class: Telegem::Markup::InlineBuilder
- Inherits:
-
Object
- Object
- Telegem::Markup::InlineBuilder
show all
- Defined in:
- lib/markup/keyboard.rb
Overview
Builder DSL for inline keyboards
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#button(text, **options) ⇒ Object
-
#callback(text, data) ⇒ Object
-
#initialize ⇒ InlineBuilder
constructor
A new instance of InlineBuilder.
-
#login(text, url, **options) ⇒ Object
-
#method_missing(name, *args, &block) ⇒ Object
-
#respond_to_missing?(name, include_private = false) ⇒ Boolean
-
#row(*buttons, &block) ⇒ Object
-
#switch_inline(text, query = "") ⇒ Object
-
#switch_inline_current(text, query = "") ⇒ Object
-
#url(text, url) ⇒ Object
-
#web_app(text, url) ⇒ Object
Constructor Details
Returns a new instance of InlineBuilder.
212
213
214
|
# File 'lib/markup/keyboard.rb', line 212
def initialize
@keyboard = InlineKeyboard.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
262
263
264
265
266
267
268
|
# File 'lib/markup/keyboard.rb', line 262
def method_missing(name, *args, &block)
if @keyboard.respond_to?(name)
@keyboard.send(name, *args, &block)
else
super
end
end
|
Instance Attribute Details
#keyboard ⇒ Object
Returns the value of attribute keyboard.
210
211
212
|
# File 'lib/markup/keyboard.rb', line 210
def keyboard
@keyboard
end
|
Instance Method Details
227
228
229
230
|
# File 'lib/markup/keyboard.rb', line 227
def button(text, **options)
@keyboard.button(text, **options)
self
end
|
#callback(text, data) ⇒ Object
237
238
239
240
|
# File 'lib/markup/keyboard.rb', line 237
def callback(text, data)
@keyboard.callback(text, data)
self
end
|
#login(text, url, **options) ⇒ Object
247
248
249
250
|
# File 'lib/markup/keyboard.rb', line 247
def login(text, url, **options)
@keyboard.login(text, url, **options)
self
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
270
271
272
|
# File 'lib/markup/keyboard.rb', line 270
def respond_to_missing?(name, include_private = false)
@keyboard.respond_to?(name) || super
end
|
#row(*buttons, &block) ⇒ Object
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/markup/keyboard.rb', line 216
def row(*buttons, &block)
if block_given?
sub_builder = InlineBuilder.new
sub_builder.instance_eval(&block)
@keyboard.row(*sub_builder.keyboard.buttons.flatten(1))
else
@keyboard.row(*buttons)
end
self
end
|
#switch_inline(text, query = "") ⇒ Object
252
253
254
255
|
# File 'lib/markup/keyboard.rb', line 252
def switch_inline(text, query = "")
@keyboard.switch_inline(text, query)
self
end
|
#switch_inline_current(text, query = "") ⇒ Object
257
258
259
260
|
# File 'lib/markup/keyboard.rb', line 257
def switch_inline_current(text, query = "")
@keyboard.switch_inline_current(text, query)
self
end
|
#url(text, url) ⇒ Object
232
233
234
235
|
# File 'lib/markup/keyboard.rb', line 232
def url(text, url)
@keyboard.url(text, url)
self
end
|
#web_app(text, url) ⇒ Object
242
243
244
245
|
# File 'lib/markup/keyboard.rb', line 242
def web_app(text, url)
@keyboard.web_app(text, url)
self
end
|