Results for: "Dir.chdir"

Returns an array with bindir attached to each executable in the executables list

creates a temporary directory with hax TODO: deprecate and remove

Redirects to url with a WEBrick::HTTPStatus::Redirect status.

Example:

res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect

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 the first element, or the first n elements, of the array. If the array is empty, the first form returns nil, and the second form returns an empty array. See also Array#last for the opposite effect.

a = [ "q", "r", "s", "t" ]
a.first     #=> "q"
a.first(2)  #=> ["q", "r"]

Extracts the nested value specified by the sequence of idx objects by calling dig at each step, returning nil if any intermediate step is nil.

a = [[1, [2, 3]]]

a.dig(0, 1, 1)                    #=> 3
a.dig(1, 2, 3)                    #=> nil
a.dig(0, 0, 0)                    #=> TypeError: Integer does not have #dig method
[42, {foo: :bar}].dig(1, :foo)    #=> :bar

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

Prints obj on the given port (default $>). Equivalent to:

def display(port=$>)
  port.write self
  nil
end

For example:

1.display
"cat".display
[ 4, 5, 6 ].display
puts

produces:

1cat[4, 5, 6]

Performs integer division: returns integer result of dividing int by numeric.

See Numeric#divmod.

Returns the floating point result of dividing integer by numeric.

654321.fdiv(13731)      #=> 47.6528293642124
654321.fdiv(13731.24)   #=> 47.6519964693647

-1234567890987654321.fdiv(13731)      #=> -89910996357705.5
-1234567890987654321.fdiv(13731.24)   #=> -89909424858035.7

Returns the array including the digits extracted by place-value notation with radix base of int.

base should be greater than or equal to 2.

12345.digits      #=> [5, 4, 3, 2, 1]
12345.digits(7)   #=> [4, 6, 6, 0, 5]
12345.digits(100) #=> [45, 23, 1]

-12345.digits(7)  #=> Math::DomainError

Performs division as each part is a float, never returns a float.

Complex(11, 22).fdiv(3)  #=> (3.6666666666666665+7.333333333333333i)

Returns float division.

Uses / to perform division, then converts the result to an integer. numeric does not define the / operator; this is left to subclasses.

Equivalent to num.divmod(numeric)[0].

See Numeric#divmod.

Returns an array containing the quotient and modulus obtained by dividing num by numeric.

If q, r = * x.divmod(y), then

q = floor(x/y)
x = q*y+r

The quotient is rounded toward -infinity, as shown in the following table:

 a    |  b  |  a.divmod(b)  |   a/b   | a.modulo(b) | a.remainder(b)
------+-----+---------------+---------+-------------+---------------
 13   |  4  |   3,    1     |   3     |    1        |     1
------+-----+---------------+---------+-------------+---------------
 13   | -4  |  -4,   -3     |  -4     |   -3        |     1
------+-----+---------------+---------+-------------+---------------
-13   |  4  |  -4,    3     |  -4     |    3        |    -1
------+-----+---------------+---------+-------------+---------------
-13   | -4  |   3,   -1     |   3     |   -1        |    -1
------+-----+---------------+---------+-------------+---------------
 11.5 |  4  |   2,    3.5   |   2.875 |    3.5      |     3.5
------+-----+---------------+---------+-------------+---------------
 11.5 | -4  |  -3,   -0.5   |  -2.875 |   -0.5      |     3.5
------+-----+---------------+---------+-------------+---------------
-11.5 |  4  |  -3,    0.5   |  -2.875 |    0.5      |    -3.5
------+-----+---------------+---------+-------------+---------------
-11.5 | -4  |   2,   -3.5   |   2.875 |   -3.5      |    -3.5

Examples

11.divmod(3)         #=> [3, 2]
11.divmod(-3)        #=> [-4, -1]
11.divmod(3.5)       #=> [3, 0.5]
(-11).divmod(3.5)    #=> [-4, 3.0]
(11.5).divmod(3.5)   #=> [3, 1.0]

Returns the Encoding object that represents the encoding of obj.

Returns float / numeric, same as Float#/.

See Numeric#divmod.

42.0.divmod 6 #=> [7, 0.0]
42.0.divmod 5 #=> [8, 2.0]

Returns the birth time for the named file.

file_name can be an IO object.

File.birthtime("testfile")   #=> Wed Apr 09 08:53:13 CDT 2003

If the platform doesn’t have birthtime, raises NotImplementedError.

Returns the birth time for file.

File.new("testfile").birthtime   #=> Wed Apr 09 08:53:14 CDT 2003

If the platform doesn’t have birthtime, raises NotImplementedError.

Divide by the specified value.

digits

If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode.

If digits is 0, the result is the same as for the / operator or quo.

If digits is not specified, the result is an integer, by analogy with Float#div; see also BigDecimal#divmod.

Examples:

a = BigDecimal("4")
b = BigDecimal("3")

a.div(b, 3)  # => 0.133e1

a.div(b, 0)  # => 0.1333333333333333333e1
a / b        # => 0.1333333333333333333e1
a.quo(b)     # => 0.1333333333333333333e1

a.div(b)     # => 1

Divides by the specified value, and returns the quotient and modulus as BigDecimal numbers. The quotient is rounded towards negative infinity.

For example:

require 'bigdecimal'

a = BigDecimal.new("42")
b = BigDecimal.new("9")

q, m = a.divmod(b)

c = q * b + m

a == c  #=> true

The quotient q is (a/b).floor, and the modulus is the amount that must be added to q * b to get a.

Performs division and returns the value as a float.

Rational(2, 3).fdiv(1)       #=> 0.6666666666666666
Rational(2, 3).fdiv(0.5)     #=> 1.3333333333333333
Rational(2).fdiv(3)          #=> 0.6666666666666666

Creates a date object denoting the given ordinal date.

The day of year should be a negative or a positive number (as a relative day from the end of year when negative). It should not be zero.

Date.ordinal(2001)        #=> #<Date: 2001-01-01 ...>
Date.ordinal(2001,34)     #=> #<Date: 2001-02-03 ...>
Date.ordinal(2001,-1)     #=> #<Date: 2001-12-31 ...>

See also ::jd and ::new.

Search took: 4ms  ·  Total Results: 1136