Class: Mysh::VarsCommand
Overview
The mysh internal variable commands.
Constant Summary collapse
- VAR_EXP =
The mysh variable parsing regex.
%r{(?<name> [a-z][a-z0-9_]*){0} (?<equals> =){0} (?<value> \S.*){0} \$ (\g<name> \s* (\g<equals> \s* \g<value>?)?)?}x
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
-
#do_command ⇒ Object
Do the actual work here.
-
#initialize(name, description) ⇒ VarsCommand
constructor
Setup an internal action.
-
#process_command(input) ⇒ Object
Execute a command against the internal mysh variables.
-
#show_all_values ⇒ Object
Display all variables neatly.
Methods inherited from Action
#action_info, #process_quick_command, #short_name
Constructor Details
#initialize(name, description) ⇒ VarsCommand
Setup an internal action.
16 17 18 19 |
# File 'lib/mysh/internal/vars.rb', line 16 def initialize(name, description) @var_name = @equals = @value = nil super(name, description) end |
Instance Method Details
#do_command ⇒ Object
Do the actual work here.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mysh/internal/vars.rb', line 34 def do_command sym = @var_name.to_sym if @var_name if @value MNV[sym] = @value elsif @equals MNV[sym] = "" elsif @var_name puts "$#{@var_name} = #{MNV.get_source(sym)}" else show_all_values end end |
#process_command(input) ⇒ Object
Execute a command against the internal mysh variables.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mysh/internal/vars.rb', line 22 def process_command(input) if (match = VAR_EXP.match(input.raw_body)) @var_name, @equals, @value = match[:name], match[:equals], match[:value] else @var_name, @equals, @value = nil end do_command :internal end |