Module: Lich::Common::UserVars
- Defined in:
- documented/common/uservars.rb
Class Method Summary collapse
-
.[](name) ⇒ String?
Retrieves the value of a user variable by name.
-
.[]=(name, val) ⇒ Object
Sets the value of a user variable by name.
-
.add(var_name, value, _t = nil) ⇒ void
Adds a value to a user variable, creating a list if necessary.
-
.change(var_name, value, _t = nil) ⇒ void
Changes the value of a user variable.
-
.delete(var_name, _t = nil) ⇒ void
Deletes a user variable by name.
-
.list ⇒ Array<String>
Returns a list of user variables.
-
.list_char ⇒ Array<String>
Returns a list of character-specific user variables.
-
.list_global ⇒ Array
Returns an empty array of global user variables.
-
.method_missing(method_name, *args) ⇒ void
Handles calls to methods that are not defined.
-
.respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Checks if the object responds to a missing method.
Class Method Details
.[](name) ⇒ String?
Retrieves the value of a user variable by name.
14 15 16 |
# File 'documented/common/uservars.rb', line 14 def self.[](name) Vars[name] end |
.[]=(name, val) ⇒ Object
Sets the value of a user variable by name.
21 22 23 |
# File 'documented/common/uservars.rb', line 21 def self.[]=(name, val) Vars[name] = val end |
.add(var_name, value, _t = nil) ⇒ void
This method returns an undefined value.
Adds a value to a user variable, creating a list if necessary.
56 57 58 59 60 61 62 63 |
# File 'documented/common/uservars.rb', line 56 def self.add(var_name, value, _t = nil) current = Vars[var_name] if current.nil? || current.empty? Vars[var_name] = value.to_s else Vars[var_name] = current.to_s.split(', ').push(value.to_s).join(', ') end end |
.change(var_name, value, _t = nil) ⇒ void
This method returns an undefined value.
Changes the value of a user variable.
47 48 49 |
# File 'documented/common/uservars.rb', line 47 def self.change(var_name, value, _t = nil) Vars[var_name] = value end |
.delete(var_name, _t = nil) ⇒ void
This method returns an undefined value.
Deletes a user variable by name.
69 70 71 |
# File 'documented/common/uservars.rb', line 69 def self.delete(var_name, _t = nil) Vars[var_name] = nil end |
.list ⇒ Array<String>
Returns a list of user variables.
7 8 9 |
# File 'documented/common/uservars.rb', line 7 def self.list Vars.list end |
.list_char ⇒ Array<String>
Returns a list of character-specific user variables.
83 84 85 |
# File 'documented/common/uservars.rb', line 83 def self.list_char Vars.list end |
.list_global ⇒ Array
Returns an empty array of global user variables.
76 77 78 |
# File 'documented/common/uservars.rb', line 76 def self.list_global Array.new end |
.method_missing(method_name, *args) ⇒ void
This method returns an undefined value.
Handles calls to methods that are not defined.
30 31 32 |
# File 'documented/common/uservars.rb', line 30 def self.method_missing(method_name, *args) Vars.method_missing(method_name, *args) end |
.respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Checks if the object responds to a missing method.
38 39 40 |
# File 'documented/common/uservars.rb', line 38 def self.respond_to_missing?(method_name, include_private = false) Vars.respond_to_missing?(method_name, include_private) end |