Class: OnyxCord::Events::PlayingEventHandler

Inherits:
EventHandler show all
Defined in:
lib/onyxcord/events/presence/playing.rb

Overview

Event handler for PlayingEvent

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #match, #matches_all

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/onyxcord/events/presence/playing.rb', line 50

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 == case a
           when String
             e.name
           when Integer
             e.id
           else
             e
           end
    end,
    matches_all(@attributes[:game], event.game) do |a, e|
      a == e
    end,
    matches_all(@attributes[:type], event.type) do |a, e|
      a == e
    end,
    matches_all(@attributes[:client_status], event.client_status) do |a, e|
      e.slice(a.keys) == a
    end
  ].reduce(true, &:&)
end