Returns the denominator (always positive).
Rational(7).denominator #=> 1 Rational(7, 1).denominator #=> 1 Rational(9, -4).denominator #=> 4 Rational(-2, -10).denominator #=> 5 rat.numerator.gcd(rat.denominator) #=> 1
Creates a date object denoting the present day.
This method is equivalent to step(max, 1){|date| …}.
This method is equivalent to step(min, -1){|date| …}.
Returns the offset in seconds between the timezone of time and UTC.
t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600
Stores the specified string value in the database, indexed via the string key provided.
Associates the value value with the specified key.
Tokenizes the Ruby program and returns an array of strings.
p Ripper.tokenize("def m(a) nil end") # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
Stores a new value
in the database with the given key
as an index.
If the key
already exists, this will update the value
associated with the key
.
Returns the given value
.
Associates the value given by value
with the key given by key
.
h = { "a" => 100, "b" => 200 } h["a"] = 9 h["c"] = 4 h #=> {"a"=>9, "b"=>200, "c"=>4} h.store("d", 42) #=> 42 h #=> {"a"=>9, "b"=>200, "c"=>4, "d"=>42}
key
should not have its value changed while it is in use as a key (an unfrozen String
passed as a key will be duplicated and frozen).
a = "a" b = "b".freeze h = { a => 100, b => 200 } h.key(100).equal? a #=> false h.key(200).equal? b #=> true
Sets the environment variable name
to value
. If the value given is nil
the environment variable is deleted. name
must be a string.
This method must be overridden by subclasses and should return the object method calls are being delegated to.
This method must be overridden by subclasses and change the object delegate to obj.
Returns the current object method calls are being delegated to.
Changes the delegate object to obj.
It’s important to note that this does not cause SimpleDelegator’s methods to change. Because of this, you probably only want to change delegation to objects of the same type as the original delegate.
Here’s an example of changing the delegation object.
names = SimpleDelegator.new(%w{James Edward Gray II}) puts names[1] # => Edward names.__setobj__(%w{Gavin Sinclair}) puts names[1] # => Sinclair
Convert a network byte ordered string form of an IP address into human readable form.
Returns a network byte ordered string form of the IP address.
Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column).
Matrix.diagonal(9, 5, -3, 4).cofactor(1, 1) => -108
Creates a single-row matrix from this vector.
Add separator in summary.
Wrapper method for getopts.rb.
params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option) # params[:a] = true # -a # params[:b] = "1" # -b1 # params[:foo] = "1" # --foo # params[:bar] = "x" # --bar x # params[:zot] = "z" # --zot Z