Class: Discordrb::Events::EventHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/events/generic.rb

Overview

Generic event handler that can be extended

Instance Method Summary collapse

Instance Method Details

#after_call(event) ⇒ Object

to be overwritten by extending event handlers



104
# File 'lib/discordrb/events/generic.rb', line 104

def after_call(event); end

#call(event) ⇒ Object

Calls this handler

Parameters:

  • event (Object)

    The event object to call this handler with



99
100
101
# File 'lib/discordrb/events/generic.rb', line 99

def call(event)
  @block.call(event)
end

#match(event) ⇒ Object

Checks whether this handler matches the given event, and then calls it.

Parameters:

  • event (Object)

    The event object to match and call the handler with



93
94
95
# File 'lib/discordrb/events/generic.rb', line 93

def match(event)
  call(event) if matches? event
end

#matches?(_) ⇒ Boolean

Whether or not this event handler matches the given event with its attributes.

Returns:

  • (Boolean)

Raises:

  • (RuntimeError)

    if this method is called - overwrite it in your event handler!



87
88
89
# File 'lib/discordrb/events/generic.rb', line 87

def matches?(_)
  raise 'Attempted to call matches?() from a generic EventHandler'
end

#matches_all(attributes, to_check, &block) ⇒ Object

See Also:

  • matches_all


107
108
109
# File 'lib/discordrb/events/generic.rb', line 107

def matches_all(attributes, to_check, &block)
  Discordrb::Events.matches_all(attributes, to_check, &block)
end