Class: Discordrb::Events::RawEventHandler

Inherits:
EventHandler show all
Defined in:
lib/discordrb/events/raw.rb

Overview

Event handler for RawEvent

Direct Known Subclasses

UnknownEventHandler

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #initialize, #match, #matches_all

Constructor Details

This class inherits a constructor from Discordrb::Events::EventHandler

Instance Method Details

#matches?(event) ⇒ Boolean


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/discordrb/events/raw.rb', line 26

def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? RawEvent

  [
    matches_all(@attributes[:type] || @attributes[:t], event.type) do |a, e|
      if a.is_a? Regexp
        # 24: update to matches?
        match = a.match(e)
        match ? (e == match[0]) : false
      else
        e.to_s.casecmp(a.to_s).zero?
      end
    end
  ].reduce(true, &:&)
end