Class: Discordrb::Await
- Inherits:
-
Object
- Object
- Discordrb::Await
- Defined in:
- lib/discordrb/await.rb
Overview
Class that represents an await to wait for a further event
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(bot, key, type, attributes, block = nil) ⇒ Await
constructor
A new instance of Await.
- #match(event) ⇒ Object
Constructor Details
#initialize(bot, key, type, attributes, block = nil) ⇒ Await
Returns a new instance of Await.
6 7 8 9 10 11 12 |
# File 'lib/discordrb/await.rb', line 6 def initialize(bot, key, type, attributes, block = nil) @bot = bot @key = key @type = type @attributes = attributes @block = block end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/discordrb/await.rb', line 4 def attributes @attributes end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/discordrb/await.rb', line 4 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/discordrb/await.rb', line 4 def type @type end |
Instance Method Details
#match(event) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/discordrb/await.rb', line 14 def match(event) dummy_handler = @bot.handler_class(@type).new(@attributes, @bot) return [nil, nil] unless dummy_handler.matches?(event) should_delete = true if (@block && @block.call(event) != false) || !@block [@key, should_delete] end |