Returns the name or string corresponding to sym.
:fred.id2name #=> "fred" :ginger.to_s #=> "ginger"
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.
Recursively deletes a directory, including all directories beneath it.
See FileUtils.rm_r
Return the path as a String
.
to_path
is implemented so Pathname
objects are usable with File.open
, etc.
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.
Returns all the bytes from the file, or the first N
if specified.
See File.binread
.
See File.lstat
.
Tokenizes the Ruby program and returns an array of strings.
p Ripper.tokenize("def m(a) nil end") # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
Return scanner state of current token.
Return true if parsed source has errors.
Iterates over the key-value pairs in the database, deleting those for which the block returns true
.
Creates a new Hash
using the key-value pairs from the database, then calls Hash#reject
with the given block, which returns a Hash
with only the key-value pairs for which the block returns false
.
Empties the database, then inserts the given key-value pairs.
This method will work with any object which implements an each_pair
method, such as a Hash
.