Class: Lich::DragonRealms::Flags
- Inherits:
-
Object
- Object
- Lich::DragonRealms::Flags
- Defined in:
- documented/dragonrealms/drinfomon/events.rb
Overview
Manages flags and matchers for the DragonRealms module This class provides methods to add, reset, delete, and access flags and their associated matchers.
Constant Summary collapse
- @@flags =
{}
- @@matchers =
{}
Class Method Summary collapse
-
.[](key) ⇒ Boolean?
Retrieves the value of a flag by its key.
-
.[]=(key, value) ⇒ Boolean
Sets the value of a flag by its key.
-
.add(key, *matchers) ⇒ void
Adds a new flag with associated matchers.
-
.delete(key) ⇒ void
Deletes a flag and its associated matchers.
-
.flags ⇒ Hash<Symbol, Boolean>
Returns all flags.
-
.matchers ⇒ Hash<Symbol, Array<Regexp>] A hash of all matchers for each flag
Returns all matchers associated with flags.
-
.reset(key) ⇒ void
Resets the value of a flag to false.
Class Method Details
.[](key) ⇒ Boolean?
Retrieves the value of a flag by its key
16 17 18 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 16 def self.[](key) @@flags[key] end |
.[]=(key, value) ⇒ Boolean
Sets the value of a flag by its key
26 27 28 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 26 def self.[]=(key, value) @@flags[key] = value end |
.add(key, *matchers) ⇒ void
This method returns an undefined value.
Adds a new flag with associated matchers
36 37 38 39 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 36 def self.add(key, *matchers) @@flags[key] = false @@matchers[key] = matchers.map { |item| item.is_a?(Regexp) ? item : /#{item}/i } end |
.delete(key) ⇒ void
This method returns an undefined value.
Deletes a flag and its associated matchers
55 56 57 58 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 55 def self.delete(key) @@matchers.delete key @@flags.delete key end |
.flags ⇒ Hash<Symbol, Boolean>
Returns all flags
64 65 66 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 64 def self.flags @@flags end |
.matchers ⇒ Hash<Symbol, Array<Regexp>] A hash of all matchers for each flag
Returns all matchers associated with flags
72 73 74 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 72 def self.matchers @@matchers end |
.reset(key) ⇒ void
This method returns an undefined value.
Resets the value of a flag to false
46 47 48 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 46 def self.reset(key) @@flags[key] = false end |