Class: Lich::DragonRealms::Flags
- Inherits:
-
Object
- Object
- Lich::DragonRealms::Flags
- Defined in:
- documented/dragonrealms/drinfomon/events.rb
Overview
Manages a set of flags and their associated matchers.
This class provides methods to add, reset, delete, and access flags.
Constant Summary collapse
- @@flags =
{}
- @@matchers =
{}
Class Method Summary collapse
-
.[](key) ⇒ Boolean?
Retrieves the value of a flag by its key.
-
.[]=(key, value) ⇒ void
Sets the value of a flag by its key.
-
.add(key, *matchers) ⇒ void
Adds a new flag with the specified key and matchers.
-
.delete(key) ⇒ void
Deletes the specified flag and its associated matchers.
-
.flags ⇒ Hash<String, Boolean>
Returns a hash of all flags.
-
.matchers ⇒ Hash<String, Array<Regexp>>
Returns a hash of all matchers associated with flags.
-
.reset(key) ⇒ void
Resets the specified flag to false.
Class Method Details
.[](key) ⇒ Boolean?
Retrieves the value of a flag by its key.
18 19 20 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 18 def self.[](key) @@flags[key] end |
.[]=(key, value) ⇒ void
This method returns an undefined value.
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 the specified key and matchers.
34 35 36 37 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 34 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 the specified flag and its associated matchers.
49 50 51 52 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 49 def self.delete(key) @@matchers.delete key @@flags.delete key end |
.flags ⇒ Hash<String, Boolean>
Returns a hash of all flags.
56 57 58 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 56 def self.flags @@flags end |
.matchers ⇒ Hash<String, Array<Regexp>>
Returns a hash of all matchers associated with flags.
62 63 64 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 62 def self.matchers @@matchers end |
.reset(key) ⇒ void
This method returns an undefined value.
Resets the specified flag to false.
42 43 44 |
# File 'documented/dragonrealms/drinfomon/events.rb', line 42 def self.reset(key) @@flags[key] = false end |