Class: Discordrb::Events::PlayingEventHandler

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

Overview

Event handler for PlayingEvent

Instance Method Summary collapse

Methods inherited from EventHandler

#call, #initialize, #match, #matches_all

Constructor Details

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

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/discordrb/events/presence.rb', line 58

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

  [
    matches_all(@attributes[:from], event.user) do |a, e|
      a == if a.is_a? String
             e.name
           elsif a.is_a? Fixnum
             e.id
           else
             e
           end
    end,
    matches_all(@attributes[:game], event.game) do |a, e|
      a == if a.is_a? String
             e.name
           else
             e
           end
    end
  ].reduce(true, &:&)
end