Method: Pathname#chdir
- Defined in:
- lib/pleasant_path/pathname.rb
#chdir ⇒ self #chdir {|working_dir| ... } ⇒ Object
Changes the current working directory to the Pathname. If no block is given, this method returns the Pathname. Otherwise, the block is called with the Pathname, the original working directory is restored after the block exits, and this method returns the return value of the block.
263 264 265 266 267 268 269 270 271 272 |
# File 'lib/pleasant_path/pathname.rb', line 263 def chdir if block_given? Dir.chdir(self) do |dir| yield dir.to_pathname end else Dir.chdir(self) self end end |