Class: Discordrb::Events::EventHandler
- Inherits:
-
Object
- Object
- Discordrb::Events::EventHandler
- Defined in:
- lib/discordrb/events/generic.rb
Overview
Generic event handler that can be extended
Direct Known Subclasses
ChannelCreateEventHandler, ChannelDeleteEventHandler, ChannelUpdateEventHandler, GuildMemberUpdateHandler, GuildRoleCreateEventHandler, GuildRoleDeleteEventHandler, GuildRoleUpdateEventHandler, MessageEventHandler, PresenceEventHandler, TrueEventHandler, TypingEventHandler, VoiceStateUpdateEventHandler
Instance Method Summary collapse
-
#initialize(attributes, block) ⇒ EventHandler
constructor
A new instance of EventHandler.
- #match(event) ⇒ Object
- #matches?(_) ⇒ Boolean
- #matches_all(attributes, to_check, &block) ⇒ Object
Constructor Details
#initialize(attributes, block) ⇒ EventHandler
Returns a new instance of EventHandler.
35 36 37 38 |
# File 'lib/discordrb/events/generic.rb', line 35 def initialize(attributes, block) @attributes = attributes @block = block end |
Instance Method Details
#match(event) ⇒ Object
44 45 46 |
# File 'lib/discordrb/events/generic.rb', line 44 def match(event) @block.call(event) if matches? event end |
#matches?(_) ⇒ Boolean
40 41 42 |
# File 'lib/discordrb/events/generic.rb', line 40 def matches?(_) fail 'Attempted to call matches?() from a generic EventHandler' end |
#matches_all(attributes, to_check, &block) ⇒ Object
48 49 50 |
# File 'lib/discordrb/events/generic.rb', line 48 def matches_all(attributes, to_check, &block) Discordrb::Events.matches_all(attributes, to_check, &block) end |