Module: Cd::Proxy

Defined in:
lib/cd.rb

Class Method Summary collapse

Class Method Details

.[email protected]Object


21
22
23
24
25
26
27
# File 'lib/cd.rb', line 21

def self.[email protected]
  if @last_path
    cd @last_path
  else
    warn "Sorry, there is no previous directory."
  end
end

.[](path) ⇒ Object


29
30
31
32
33
34
# File 'lib/cd.rb', line 29

def self.[](path)
  next_last_path = pwd
  FileUtils::Verbose.cd File.expand_path(path)
  @last_path = next_last_path
  Cd::Proxy.ls
end

.inspectObject


44
45
46
# File 'lib/cd.rb', line 44

def self.inspect
  "#{to_s}[#{pwd.inspect}]"
end

.ls(path = '.') ⇒ Object


36
37
38
# File 'lib/cd.rb', line 36

def self.ls(path = '.')
  Dir["#{path}/*"].map{ |filename| File.basename filename }
end

.pwdObject


40
41
42
# File 'lib/cd.rb', line 40

def self.pwd
  FileUtils.pwd
end

.~Object


17
18
19
# File 'lib/cd.rb', line 17

def self.~
  cd '~'
end