Class: AliasChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/shell/alias_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ AliasChecker



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shell/alias_checker.rb', line 4

def initialize(filename)
  @filename = filename

  if !File.exist?(File.expand_path(filename))
    return
  end

  file_contents = File.open(File.expand_path(filename), 'r').read
  lines = file_contents.split("\n")
  @aliases = {}
  lines.each do |l|
    al = AliasLine.new(l)
    @aliases[al.alias_name] = al.command
  end
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



2
3
4
# File 'lib/shell/alias_checker.rb', line 2

def aliases
  @aliases
end

#filenameObject

Returns the value of attribute filename.



2
3
4
# File 'lib/shell/alias_checker.rb', line 2

def filename
  @filename
end

Instance Method Details

#exist?(alias_name) ⇒ Boolean



20
21
22
# File 'lib/shell/alias_checker.rb', line 20

def exist?(alias_name)
  @aliases && !!@aliases[alias_name]
end