Class: Telegem::Markup::Builder
- Inherits:
-
Object
- Object
- Telegem::Markup::Builder
- Defined in:
- lib/markup/keyboard.rb
Overview
Builder DSL for keyboards
Instance Attribute Summary collapse
-
#keyboard ⇒ Object
readonly
Returns the value of attribute keyboard.
Instance Method Summary collapse
- #button(text, **options) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #row(*buttons, &block) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
175 176 177 |
# File 'lib/markup/keyboard.rb', line 175 def initialize @keyboard = Keyboard.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
195 196 197 198 199 200 201 |
# File 'lib/markup/keyboard.rb', line 195 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 (readonly)
Returns the value of attribute keyboard.
173 174 175 |
# File 'lib/markup/keyboard.rb', line 173 def keyboard @keyboard end |
Instance Method Details
#button(text, **options) ⇒ Object
190 191 192 193 |
# File 'lib/markup/keyboard.rb', line 190 def (text, **) @keyboard.(text, **) self end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
203 204 205 |
# File 'lib/markup/keyboard.rb', line 203 def respond_to_missing?(name, include_private = false) @keyboard.respond_to?(name) || super end |
#row(*buttons, &block) ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/markup/keyboard.rb', line 179 def row(*, &block) if block_given? sub_builder = Builder.new sub_builder.instance_eval(&block) @keyboard.row(*sub_builder.keyboard..flatten(1)) else @keyboard.row(*) end self end |