Returns a Digest
subclass by name
in a thread-safe manner even when on-demand loading is involved.
require 'digest' Digest("MD5") # => Digest::MD5 Digest(:SHA256) # => Digest::SHA256 Digest(:Foo) # => LoadError: library not found for class Digest::Foo -- digest/foo
cgi_runner.rb – CGI
launcher.
Author: IPR – Internet Programming with Ruby – writers Copyright © 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU Copyright © 2002 Internet Programming with Ruby writers. All rights reserved.
$IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $
Deprecated method that is equivalent to taint
.
Deprecated method that is equivalent to tainted?
.
Deprecated method that is equivalent to untaint
.
Prevents further modifications to obj. A RuntimeError
will be raised if modification is attempted. There is no way to unfreeze a frozen object. See also Object#frozen?
.
This method returns self.
a = [ "a", "b", "c" ] a.freeze a << "z"
produces:
prog.rb:3:in `<<': can't modify frozen Array (FrozenError) from prog.rb:3
Objects of the following classes are always frozen: Integer
, Float
, Symbol
.
Returns a string representing obj. The default to_s
prints the object’s class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns “main”.
Returns the value of int
as a BigDecimal
.
require 'bigdecimal' require 'bigdecimal/util' 42.to_d # => 0.42e2
See also BigDecimal::new
.
Returns a string containing the place-value representation of int
with radix base
(between 2 and 36).
12345.to_s #=> "12345" 12345.to_s(2) #=> "11000000111001" 12345.to_s(8) #=> "30071" 12345.to_s(10) #=> "12345" 12345.to_s(16) #=> "3039" 12345.to_s(36) #=> "9ix" 78546939656932.to_s(36) #=> "rubyrules"
Iterates the given block, passing in integer values from int
up to and including limit
.
If no block is given, an Enumerator
is returned instead.
5.upto(10) {|i| print i, " " } #=> 5 6 7 8 9 10
Iterates the given block, passing in decreasing values from int
down to and including limit
.
If no block is given, an Enumerator
is returned instead.
5.downto(1) { |n| print n, ".. " } puts "Liftoff!" #=> "5.. 4.. 3.. 2.. 1.. Liftoff!"
Returns the predecessor of int
, i.e. the Integer
equal to int-1
.
1.pred #=> 0 (-1).pred #=> -2
Returns the int
itself.
97.ord #=> 97
This method is intended for compatibility to character literals in Ruby 1.9.
For example, ?a.ord
returns 97 both in 1.8 and 1.9.
Returns the largest number less than or equal to int
with a precision of ndigits
decimal digits (default: 0).
When the precision is negative, the returned value is an integer with at least ndigits.abs
trailing zeros.
Returns self
when ndigits
is zero or positive.
1.floor #=> 1 1.floor(2) #=> 1 18.floor(-1) #=> 10 (-18).floor(-1) #=> -20
Returns the remainder after dividing int
by numeric
.
x.remainder(y)
means x-y*(x/y).truncate
.
5.remainder(3) #=> 2 -5.remainder(3) #=> -2 5.remainder(-3) #=> 2 -5.remainder(-3) #=> -2 5.remainder(1.5) #=> 0.5
See Numeric#divmod
.
Returns the value as a rational.
1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns false.
Returns the value as a string.
Complex(2).to_s #=> "2+0i" Complex('-8/6').to_s #=> "-4/3+0i" Complex('1/2i').to_s #=> "0+1/2i" Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i" Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i"