Returns true if the contents of a stream a
and b
are identical.
Returns true if the contents of a stream a
and b
are identical.
No longer raises NoMemoryError
when allocating an instance of the given classes.
Quietly ensure the Gem
directory dir
contains all the proper subdirectories for handling default gems. If we can’t create a directory due to a permission problem, then we will silently continue.
If mode
is given, missing directories are created with this mode.
World-writable directories will never be created.
Returns true
if the named file is a directory, or a symlink that points at a directory, and false
otherwise.
file_name can be an IO
object.
File.directory?(".")
Returns the number of the signal that caused stat to stop (or nil
if self is not stopped).
Restore session state from the session’s FileStore
file.
Returns the session state as a hash.
Restore (empty) session state.
Returns self.
Returns 1.
Returns the numerator.
1 2 3+4i <- numerator - + -i -> ---- 2 3 6 <- denominator c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i) n = c.numerator #=> (3+4i) d = c.denominator #=> 6 n / d #=> ((1/2)+(2/3)*i) Complex(Rational(n.real, d), Rational(n.imag, d)) #=> ((1/2)+(2/3)*i)
See denominator.
Returns the denominator (lcm of both denominator - real and imag).
See numerator.
Returns the numerator.
Returns the denominator (always positive).
Returns the numerator. The result is machine dependent.
n = 0.3.numerator #=> 5404319552844595 d = 0.3.denominator #=> 18014398509481984 n.fdiv(d) #=> 0.3
See also Float#denominator
.
Returns the denominator (always positive). The result is machine dependent.
See also Float#numerator
.
Calls the block once for each entry in the named directory, passing the filename of each entry as a parameter to the block.
If no block is given, an enumerator is returned instead.
Dir.foreach("testdir") {|x| puts "Got #{x}" }
produces:
Got . Got .. Got config.h Got main.rb
Returns the numerator.
Rational(7).numerator #=> 7 Rational(7, 1).numerator #=> 7 Rational(9, -4).numerator #=> -9 Rational(-2, -10).numerator #=> 1
Returns the denominator (always positive).
Rational(7).denominator #=> 1 Rational(7, 1).denominator #=> 1 Rational(9, -4).denominator #=> 4 Rational(-2, -10).denominator #=> 5
Returns true if the date is on or after the day of calendar reform.
Date.new(1582,10,15).gregorian? #=> true (Date.new(1582,10,15) - 1).gregorian? #=> false
This method is equivalent to new_start
(Date::GREGORIAN
).
Executes the block for every line in the named I/O port, where lines are separated by sep.
If no block is given, an enumerator is returned instead.
If name
starts with a pipe character ("|"
) and the receiver is the IO
class, a subprocess is created in the same way as Kernel#open
, and its output is returned. Consider to use File.foreach
to disable the behavior of subprocess invocation.
File.foreach("testfile") {|x| print "GOT ", x } IO.foreach("| cat testfile") {|x| print "GOT ", x }
produces:
GOT This is line one GOT This is line two GOT This is line three GOT And so on...
If the last argument is a hash, it’s the keyword argument to open. See IO.readlines
for details about getline_args. And see also IO.read
for details about open_args.