Module: Discordrb::Events
- Included in:
- Bot
- Defined in:
- lib/discordrb/events/typing.rb,
lib/discordrb/events/generic.rb,
lib/discordrb/events/message.rb,
lib/discordrb/events/lifetime.rb,
lib/discordrb/events/presence.rb
Defined Under Namespace
Classes: DisconnectEvent, DisconnectEventHandler, EventHandler, MentionEvent, MentionEventHandler, MessageEvent, MessageEventHandler, Negated, PresenceEvent, PresenceEventHandler, ReadyEvent, ReadyEventHandler, TrueEventHandler, TypingEvent, TypingEventHandler
Class Method Summary collapse
Class Method Details
.matches_all(attributes, to_check, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/discordrb/events/generic.rb', line 7 def self.matches_all(attributes, to_check, &block) # "Zeroth" case: attributes is nil return true unless attributes # First case: there's a single negated attribute if attributes.is_a? Negated # The contained object might also be an array, so recursively call matches_all (and negate the result) return !matches_all(attributes.object, to_check, &block) end # Second case: there's a single, not-negated attribute unless attributes.is_a? Array return yield(attributes, to_check) end # Third case: it's an array of attributes attributes.reduce(false) do |result, element| result || yield(element, to_check) end end |