Class: Alis::Alias
- Inherits:
-
Object
- Object
- Alis::Alias
- Defined in:
- lib/alis/alias.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
writeonly
Sets the attribute args.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #cmd ⇒ Object
- #execute ⇒ Object
- #init_args_from_passed_params(prms) ⇒ Object
-
#initialize(cmd_name, params, exe, tail) ⇒ Alias
constructor
A new instance of Alias.
- #remove ⇒ Object
Constructor Details
#initialize(cmd_name, params, exe, tail) ⇒ Alias
Returns a new instance of Alias.
10 11 12 13 |
# File 'lib/alis/alias.rb', line 10 def initialize(cmd_name, params, exe, tail) @cmd_name, @params, @exe, @tail = cmd_name, params, exe, tail @args = [] end |
Instance Attribute Details
#args=(value) ⇒ Object (writeonly)
Sets the attribute args
3 4 5 |
# File 'lib/alis/alias.rb', line 3 def args=(value) @args = value end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/alis/alias.rb', line 4 def params @params end |
Class Method Details
Instance Method Details
#cmd ⇒ Object
15 16 17 |
# File 'lib/alis/alias.rb', line 15 def cmd Alis.store.get_cmd(@cmd_name) end |
#execute ⇒ Object
23 24 25 26 27 28 |
# File 'lib/alis/alias.rb', line 23 def execute exes = @exe.split(/\s/) exes = [Alis.full_path_for_cmd(exes[0])] + exes[1..-1] exe = exes.join(' ') system "#{exe} #{@args.join(' ')} #{@tail}" end |
#init_args_from_passed_params(prms) ⇒ Object
19 20 21 |
# File 'lib/alis/alias.rb', line 19 def init_args_from_passed_params(prms) @args = prms[@params.size..-1] end |
#remove ⇒ Object
30 31 32 |
# File 'lib/alis/alias.rb', line 30 def remove @cmd.remove_alias(@params) end |