Class: Discorb::Event
- Inherits:
-
Object
- Object
- Discorb::Event
- Defined in:
- lib/discorb/event.rb
Overview
Represents a event. This class shouldn't be instantiated directly. Use Client#on instead.
Instance Attribute Summary collapse
-
#block -> Proc
readonly
The block to be called.
-
#discriminator -> Hash
readonly
The event discriminator.
-
#id -> Symbol
readonly
The event id.
-
#once -> Boolean
(also: #once?)
readonly
Whether the event is once or not.
Instance Method Summary collapse
-
#call -> Object
Calls the block associated with the event.
-
#initialize(block, id, discriminator) -> Event
constructor
A new instance of Event.
Constructor Details
#initialize(block, id, discriminator) -> Event
Returns a new instance of Event.
20 21 22 23 24 25 26 |
# File 'lib/discorb/event.rb', line 20 def initialize(block, id, discriminator) @block = block @id = id @once = discriminator.fetch(:once, false) @discriminator = discriminator @rescue = nil end |
Instance Attribute Details
#block -> Proc (readonly)
Returns the block to be called.
11 12 13 |
# File 'lib/discorb/event.rb', line 11 def block @block end |
#discriminator -> Hash (readonly)
Returns the event discriminator.
15 16 17 |
# File 'lib/discorb/event.rb', line 15 def discriminator @discriminator end |
#id -> Symbol (readonly)
Returns the event id.
13 14 15 |
# File 'lib/discorb/event.rb', line 13 def id @id end |
#once -> Boolean (readonly) Also known as: once?
Returns whether the event is once or not.
17 18 19 |
# File 'lib/discorb/event.rb', line 17 def once @once end |
Instance Method Details
#call -> Object
Calls the block associated with the event.
31 32 33 |
# File 'lib/discorb/event.rb', line 31 def call(...) @block.call(...) end |