Module: Lich::Common::UserVars

Defined in:
documented/common/uservars.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ String?

Retrieves the value of a user variable by name.

Parameters:

  • name (String) —

    the name of the variable

Returns:

  • (String, nil) —

    the value of the variable or nil if not found



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.

Parameters:

  • name (String) —

    the name of the variable

  • val (String) —

    the value to set



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.

Parameters:

  • var_name (String) —

    the name of the variable

  • value (String) —

    the value to add

  • _t (nil) (defaults to: nil) —

    an optional parameter (unused)



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.

Parameters:

  • var_name (String) —

    the name of the variable

  • value (String) —

    the new value to set

  • _t (nil) (defaults to: nil) —

    an optional parameter (unused)



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.

Parameters:

  • var_name (String) —

    the name of the variable to delete

  • _t (nil) (defaults to: nil) —

    an optional parameter (unused)



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.

Returns:



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.

Returns:



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.

Returns:

  • (Array)


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.

Parameters:

  • method_name (Symbol) —

    the name of the method

  • args (Array) —

    arguments passed to the method



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.

Parameters:

  • method_name (Symbol) —

    the name of the method

  • include_private (Boolean) (defaults to: false) —

    whether to include private methods

Returns:

  • (Boolean) —

    true if the method is available, false otherwise



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