Class: Telegram::Callback
- Inherits:
-
Object
- Object
- Telegram::Callback
- Defined in:
- lib/telegram/callback.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #callback(&cb) ⇒ Object
- #errback(&cb) ⇒ Object
-
#initialize ⇒ Callback
constructor
A new instance of Callback.
- #trigger(type = :success, data = nil) ⇒ Object
Constructor Details
#initialize ⇒ Callback
5 6 7 8 9 |
# File 'lib/telegram/callback.rb', line 5 def initialize @success = nil @fail = nil @data = nil end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/telegram/callback.rb', line 3 def data @data end |
Instance Method Details
#callback(&cb) ⇒ Object
11 12 13 |
# File 'lib/telegram/callback.rb', line 11 def callback(&cb) @success = cb end |
#errback(&cb) ⇒ Object
15 16 17 |
# File 'lib/telegram/callback.rb', line 15 def errback(&cb) @fail = cb end |
#trigger(type = :success, data = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/telegram/callback.rb', line 19 def trigger(type = :success, data = nil) @data = data case type when :success @success.call when :fail @fail.call end end |