Class: AliasManager::Alias

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stringObject

Returns the value of attribute string

Returns:

  • (Object)

    the current value of string



2
3
4
# File 'lib/alias_manager/alias.rb', line 2

def string
  @string
end

Class Method Details

.allObject



4
5
6
7
8
9
10
# File 'lib/alias_manager/alias.rb', line 4

def self.all
  @all ||= `echo "source #{ENV['HOME']}/.zshrc; alias -L" | /bin/zsh`.split("\n").select do |alias_line|
    alias_line[/alias\s+[^=]*=/]
  end.map do |string|
    new(string)
  end
end

Instance Method Details

#abbreviationObject



12
13
14
# File 'lib/alias_manager/alias.rb', line 12

def abbreviation
  string.match(/alias\s+([^=]*)=/)[1]
end

#commandObject



16
17
18
# File 'lib/alias_manager/alias.rb', line 16

def command
  string.match(/='?"?([^'"]*)'?"?/)[1]
end