Module: Discordrb::Events
- Included in:
- Bot
- Defined in:
- lib/discordrb/events/generic.rb,
lib/discordrb/events/typing.rb,
lib/discordrb/events/message.rb,
lib/discordrb/events/lifetime.rb,
lib/discordrb/events/presence.rb,
lib/discordrb/events/channel_create.rb,
lib/discordrb/events/channel_delete.rb,
lib/discordrb/events/channel_update.rb,
lib/discordrb/events/guild_role_create.rb,
lib/discordrb/events/guild_role_delete.rb,
lib/discordrb/events/guild_role_update.rb,
lib/discordrb/events/voice_state_update.rb,
lib/discordrb/events/guild_member_update.rb
Overview
Events used by discordrb
Defined Under Namespace
Classes: ChannelCreateEvent, ChannelCreateEventHandler, ChannelDeleteEvent, ChannelDeleteEventHandler, ChannelUpdateEvent, ChannelUpdateEventHandler, DisconnectEvent, DisconnectEventHandler, EventHandler, GuildMemberUpdateEvent, GuildMemberUpdateHandler, GuildRoleCreateEvent, GuildRoleCreateEventHandler, GuildRoleDeleteEvent, GuildRoleDeleteEventHandler, GuildRoleUpdateEvent, GuildRoleUpdateEventHandler, MentionEvent, MentionEventHandler, MessageEvent, MessageEventHandler, Negated, PresenceEvent, PresenceEventHandler, ReadyEvent, ReadyEventHandler, TrueEventHandler, TypingEvent, TypingEventHandler, VoiceStateUpdateEvent, VoiceStateUpdateEventHandler
Class Method Summary collapse
Class Method Details
.matches_all(attributes, to_check, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/discordrb/events/generic.rb', line 14 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 return yield(attributes, to_check) unless attributes.is_a? Array # Third case: it's an array of attributes attributes.reduce(false) do |result, element| result || yield(element, to_check) end end |