D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Dir
/
Filename :
chdir-c.ri
back
Copy
U:RDoc::AnyMethod[iI" chdir:ETI"Dir::chdir;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"+Changes the current working directory.;To:RDoc::Markup::BlankLine o; ; [I"/With argument +new_dirpath+ and no block, ;TI"$changes to the given +dirpath+:;T@o:RDoc::Markup::Verbatim; [I"%Dir.pwd # => "/example" ;TI"Dir.chdir('..') # => 0 ;TI"Dir.pwd # => "/" ;T:@format0o; ; [I"#With no argument and no block:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"DChanges to the value of environment variable +HOME+ if defined.;To;;0; [o; ; [I"POtherwise changes to the value of environment variable +LOGDIR+ if defined.;To;;0; [o; ; [I"Otherwise makes no change.;T@o; ; [I"XWith argument +new_dirpath+ and a block, temporarily changes the working directory:;T@o;;;;[ o;;0; [o; ; [I"'Calls the block with the argument.;To;;0; [o; ; [I"$Changes to the given directory.;To;;0; [o; ; [I"0Executes the block (yielding the new path).;To;;0; [o; ; [I"-Restores the previous working directory.;To;;0; [o; ; [I"&Returns the block's return value.;T@o; ; [I" Example:;T@o;; [I""Dir.chdir('/var/spool/mail') ;TI"&Dir.pwd # => "/var/spool/mail" ;TI"Dir.chdir('/tmp') do ;TI" Dir.pwd # => "/tmp" ;TI" end ;TI"&Dir.pwd # => "/var/spool/mail" ;T; 0o; ; [I"#With no argument and a block, ;TI"Acalls the block with the current working directory (string) ;TI"*and returns the block's return value.;T@o; ; [I"3Calls to \Dir.chdir with blocks may be nested:;T@o;; [I""Dir.chdir('/var/spool/mail') ;TI"(Dir.pwd # => "/var/spool/mail" ;TI"Dir.chdir('/tmp') do ;TI" Dir.pwd # => "/tmp" ;TI" Dir.chdir('/usr') do ;TI" Dir.pwd # => "/usr" ;TI" end ;TI" Dir.pwd # => "/tmp" ;TI" end ;TI"(Dir.pwd # => "/var/spool/mail" ;T; 0o; ; [ I"IIn a multi-threaded program an error is raised if a thread attempts ;TI"@to open a +chdir+ block while another thread has one open, ;TI"8or a call to +chdir+ without a block occurs inside ;TI"9a block passed to +chdir+ (even in the same thread).;T@o; ; [I"@Raises an exception if the target directory does not exist.;T: @fileI" dir.c;T:0@omit_headings_from_table_of_contents_below0I"�Dir.chdir(new_dirpath) -> 0 Dir.chdir -> 0 Dir.chdir(new_dirpath) {|new_dirpath| ... } -> object Dir.chdir {|cur_dirpath| ... } -> object ;T0[ I"(*args);T@rFI"Dir;TcRDoc::NormalClass00