Returns clean pathname of self
with consecutive slashes and useless dots removed. The filesystem is not accessed.
If consider_symlink
is true
, then a more conservative algorithm is used to avoid breaking symbolic linkages. This may retain more ..
entries than absolutely necessary, but without accessing the filesystem, this can’t be avoided.
See Pathname#realpath
.
The opposite of Pathname#absolute?
It returns false
if the pathname begins with a slash.
p = Pathname.new('/im/sure') p.relative? #=> false p = Pathname.new('not/so/sure') p.relative? #=> true
Returns the children of the directory (files and subdirectories, not recursive) as an array of Pathname
objects.
By default, the returned pathnames will have enough information to access the files. If you set with_directory
to false
, then the returned pathnames will contain the filename only.
For example:
pn = Pathname("/usr/lib/ruby/1.8") pn.children # -> [ Pathname:/usr/lib/ruby/1.8/English.rb, Pathname:/usr/lib/ruby/1.8/Env.rb, Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ] pn.children(false) # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
Note that the results never contain the entries .
and ..
in the directory because they are not children.
Creates a full path, including any intermediate directories that don’t yet exist.
See FileUtils.mkpath
and FileUtils.mkdir_p
Returns the real (absolute) pathname for self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
All components of the pathname must exist when this method is called.
Returns the real (absolute) pathname of self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
The last component of the real pathname can be nonexistent.
See File.lstat
.
Checks the status of the child process specified by pid
. Returns nil
if the process is still alive.
If the process is not alive, and raise
was true, a PTY::ChildExited
exception will be raised. Otherwise it will return a Process::Status
instance.
pid
The process id of the process to check
raise
If true
and the process identified by pid
is no longer alive a PTY::ChildExited
is raised.
creates a new socket object connected to host:port using TCP/IP.
If local_host:local_port is given, the socket is bound to it.
The optional last argument opts is options represented by a hash. opts may have following options:
specify the timeout in seconds.
If a block is given, the block is called with the socket. The value of the block is returned. The socket is closed when this method returns.
If no block is given, the socket is returned.
Socket.tcp("www.ruby-lang.org", 80) {|sock| sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" sock.close_write puts sock.read }
iterates over the list of Addrinfo
objects obtained by Addrinfo.getaddrinfo
.
Addrinfo.foreach(nil, 80) {|x| p x } #=> #<Addrinfo: 127.0.0.1:80 TCP (:80)> # #<Addrinfo: 127.0.0.1:80 UDP (:80)> # #<Addrinfo: [::1]:80 TCP (:80)> # #<Addrinfo: [::1]:80 UDP (:80)>
returns an addrinfo object for TCP address.
Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
Returns the path of the local address of unixsocket.
s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock"
Sets the data mode in self
to binary mode; see Data Mode.
Calls the block with each remaining line read from the stream; does nothing if already at end-of-file; returns self
. See Line IO.
Reads and returns the next character from the stream; see Character IO.
Pushes back (“unshifts”) a character or integer onto the stream; see Character IO.
See IO#putc
.