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.



31
32
33
34
# File 'lib/discordrb/events/generic.rb', line 31

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

Instance Method Details

#match(event) ⇒ Object



40
41
42
# File 'lib/discordrb/events/generic.rb', line 40

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

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/discordrb/events/generic.rb', line 36

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

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



44
45
46
# File 'lib/discordrb/events/generic.rb', line 44

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