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

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

Returns:

  • (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