Pushes back one character (passed as a parameter) onto ios, such that a subsequent buffered character read will return it. Only one character may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several characters that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread
).
f = File.new("testfile") #=> #<File:testfile> c = f.getc #=> "8" f.ungetc(c) #=> nil f.getc #=> "8"
Reorganizes the database file. This operation removes reserved space of elements that have already been deleted. It is only useful after a lot of deletions in the database.
Returns true
if self
points to a mountpoint.
Removes a file or directory, using File.unlink
if self
is a file, or Dir.unlink
as necessary.
This method is called when strong warning is produced by the parser. fmt
and args
is printf style.
Tokenizes the Ruby program and returns an array of strings.
p Ripper.tokenize("def m(a) nil end") # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
Pushes back one character (passed as a parameter) onto strio such that a subsequent buffered read will return it. There is no limitation for multiple pushbacks including pushing back behind the beginning of the buffer string.
Truncates the buffer string to at most integer bytes. The strio must be opened for writing.
Set
the scan pointer to the previous position. Only one previous position is remembered, and it changes with each scanning operation.
s = StringScanner.new('test string') s.scan(/\w+/) # => "test" s.unscan s.scan(/../) # => "te" s.scan(/\d/) # => nil s.unscan # ScanError: unscan failed: previous match record not exist
disconnects OLE server. If this method called, then the WIN32OLE_EVENT
object does not receive the OLE server event any more. This method is trial implementation.
ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event() {...} ... ev.unadvise
Untrust both the object returned by _getobj_ and self.
Untaint both the object returned by _getobj_ and self.
Generate results and print them. (see ERB#result
)
Log an UNKNOWN
message. This will be printed no matter what the logger’s level is.
See info
for more information.
Returns a matrix with entries rounded to the given precision (see Float#round
)
Returns a vector with entries rounded to the given precision (see Float#round
)
Returns the modulus (Pythagorean distance) of the vector.
Vector[5,8,2].r => 9.643650761
As int
is already an Integer
, all these methods simply return the receiver.
Rounds int
to a given precision in decimal digits (default 0 digits).
Precision may be negative. Returns a floating point number when ndigits
is positive, self
for zero, and round down for negative.
1.round #=> 1 1.round(2) #=> 1.0 15.round(-1) #=> 20
Unlinks (deletes) the file from the filesystem. One should always unlink the file after using it, as is explained in the “Explicit close” good practice section in the Tempfile
overview:
file = Tempfile.new('foo') begin ...do something with file... ensure file.close file.unlink # deletes the temp file end
On POSIX systems it’s possible to unlink a file before closing it. This practice is explained in detail in the Tempfile
overview (section “Unlink after creation”); please refer there for more information.
However, unlink-before-close may not be supported on non-POSIX operating systems. Microsoft Windows is the most notable case: unlinking a non-closed file will result in an error, which this method will silently ignore. If you want to practice unlink-before-close whenever possible, then you should write code like this:
file = Tempfile.new('foo') file.unlink # On Windows this silently fails. begin ... do something with file ... ensure file.close! # Closes the file handle. If the file wasn't unlinked # because #unlink failed, then this method will attempt # to do so again. end
Returns true
if any thread has terminated and is ready to be collected.