Module: Mysh::MNV
- Defined in:
- lib/mysh/shell_variables/shell_variable_store.rb
Overview
The holder of mysh variables.
Class Method Summary collapse
-
.[](index) ⇒ Object
Get the value of a variable.
-
.[]=(index, value) ⇒ Object
Set the value of a variable.
-
.delete_keeper(index) ⇒ Object
Delete the value keeper of a variable.
-
.get_keeper(index) ⇒ Object
Get the value keeper of a variable.
-
.get_source(index) ⇒ Object
Get the source code of a variable.
-
.key?(index) ⇒ Boolean
Does this entry exist?.
-
.keys ⇒ Object
Get all the keys.
-
.set_keeper(index, keeper) ⇒ Object
Set the value keeper of a variable.
Class Method Details
.[](index) ⇒ Object
Get the value of a variable. Endemic Code Smells :reek:TooManyStatements
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 16 def self.[](index) keeper = get_keeper(index) if @loop_check keeper.get_value(@loop_check) else begin keeper.get_value(@loop_check = {}) ensure @loop_check = nil end end end |
.[]=(index, value) ⇒ Object
Set the value of a variable.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 31 def self.[]=(index, value) unless value.empty? keeper = get_keeper(index) keeper.set_value(value) set_keeper(index, keeper) else delete_keeper(index) end value end |
.delete_keeper(index) ⇒ Object
Delete the value keeper of a variable.
54 55 56 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 54 def self.delete_keeper(index) @store.delete(index) end |
.get_keeper(index) ⇒ Object
Get the value keeper of a variable.
44 45 46 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 44 def self.get_keeper(index) @store[index] end |
.get_source(index) ⇒ Object
Get the source code of a variable.
59 60 61 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 59 def self.get_source(index) @store[index].get_source end |
.key?(index) ⇒ Boolean
Does this entry exist?
64 65 66 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 64 def self.key?(index) @store.key?(index) end |
.keys ⇒ Object
Get all the keys
69 70 71 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 69 def self.keys @store.keys end |
.set_keeper(index, keeper) ⇒ Object
Set the value keeper of a variable.
49 50 51 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 49 def self.set_keeper(index, keeper) @store[index] = keeper end |