Class: Discordrb::Events::EventHandler

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes, block) ⇒ EventHandler

Returns a new instance of EventHandler.



29
30
31
32
# File 'lib/discordrb/events/generic.rb', line 29

def initialize(attributes, block)
  @attributes = attributes
  @block = block
end

Instance Method Details

#match(event) ⇒ Object



38
39
40
# File 'lib/discordrb/events/generic.rb', line 38

def match(event)
  @block.call(event) if matches? event
end

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/discordrb/events/generic.rb', line 34

def matches?(event)
  raise "Attempted to call matches?() from a generic EventHandler"
end

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



42
43
44
# File 'lib/discordrb/events/generic.rb', line 42

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