Class: Alis::Alias

Inherits:
Object
  • Object
show all
Defined in:
lib/alis/alias.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute args to.



3
4
5
# File 'lib/alis/alias.rb', line 3

def args=(value)
  @args = value
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/alis/alias.rb', line 4

def params
  @params
end

Class Method Details

.get(cmd_name, params) ⇒ Object



6
7
8
# File 'lib/alis/alias.rb', line 6

def self.get(cmd_name, params)
  Alis.store.get_alias(cmd_name, params)
end

Instance Method Details

#cmdObject



15
16
17
# File 'lib/alis/alias.rb', line 15

def cmd
  Alis.store.get_cmd(@cmd_name)
end

#executeObject



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

#removeObject



30
31
32
# File 'lib/alis/alias.rb', line 30

def remove
  @cmd.remove_alias(@params)
end