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
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 17 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.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 32 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.
55 56 57 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 55 def self.delete_keeper(index) @store.delete(index) end |
.get_keeper(index) ⇒ Object
Get the value keeper of a variable.
45 46 47 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 45 def self.get_keeper(index) @store[index] end |
.get_source(index) ⇒ Object
Get the source code of a variable.
60 61 62 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 60 def self.get_source(index) @store[index].get_source end |
.key?(index) ⇒ Boolean
Does this entry exist?
65 66 67 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 65 def self.key?(index) @store.key?(index) end |
.keys ⇒ Object
Get all the keys
70 71 72 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 70 def self.keys @store.keys end |
.set_keeper(index, keeper) ⇒ Object
Set the value keeper of a variable.
50 51 52 |
# File 'lib/mysh/shell_variables/shell_variable_store.rb', line 50 def self.set_keeper(index, keeper) @store[index] = keeper end |