Results for: "module_function"

Returns true if rat is less than 0.

Returns rat rounded to the nearest value 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 a rational when ndigits is positive, otherwise returns an integer.

Rational(3).round      #=> 3
Rational(2, 3).round   #=> 1
Rational(-3, 2).round  #=> -2

  #    decimal      -  1  2  3 . 4  5  6
  #                   ^  ^  ^  ^   ^  ^
  #   precision      -3 -2 -1  0  +1 +2

Rational('-123.456').round(+1).to_f  #=> -123.5
Rational('-123.456').round(-1)       #=> -120

The optional half keyword argument is available similar to Float#round.

Rational(25, 100).round(1, half: :up)    #=> (3/10)
Rational(25, 100).round(1, half: :down)  #=> (1/5)
Rational(25, 100).round(1, half: :even)  #=> (1/5)
Rational(35, 100).round(1, half: :up)    #=> (2/5)
Rational(35, 100).round(1, half: :down)  #=> (3/10)
Rational(35, 100).round(1, half: :even)  #=> (2/5)
Rational(-25, 100).round(1, half: :up)   #=> (-3/10)
Rational(-25, 100).round(1, half: :down) #=> (-1/5)
Rational(-25, 100).round(1, half: :even) #=> (-1/5)

Returns the value as a string for inspection.

Rational(2).inspect      #=> "(2/1)"
Rational(-8, 6).inspect  #=> "(-4/3)"
Rational('1/2').inspect  #=> "(1/2)"

Returns a nicely-formatted string representation of self:

/ab+c/ix.inspect # => "/ab+c/ix"

Related: Regexp#to_s.

It returns the timeout interval for Regexp matching in second. nil means no default timeout configuration.

This configuration is per-object. The global configuration set by Regexp.timeout= is ignored if per-object configuration is set.

re = Regexp.new("^a*b?a*$", timeout: 1)
re.timeout               #=> 1.0
re =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError)

It returns the current default timeout interval for Regexp matching in second. nil means no default timeout configuration.

It sets the default timeout interval for Regexp matching in second. nil means no default timeout configuration. This configuration is process-global. If you want to set timeout for each Regexp, use timeout keyword for Regexp.new.

Regexp.timeout = 1
/^a*b?a*$/ =~ "a" * 100000 + "x" #=> regexp match timeout (RuntimeError)

Returns true if the set contains the given object.

Note that include? and member? do not test member equality using == as do other Enumerables.

See also Enumerable#include?

Returns true if the set and the given enumerable have at least one element in common.

Set[1, 2, 3].intersect? Set[4, 5]   #=> false
Set[1, 2, 3].intersect? Set[3, 4]   #=> true
Set[1, 2, 3].intersect? 4..5        #=> false
Set[1, 2, 3].intersect? [3, 4]      #=> true

Equivalent to Set#delete_if, but returns nil if no changes were made. Returns an enumerator if no block is given.

Deletes every element that appears in the given enumerable object and returns self.

No documentation available

Returns a string containing a human-readable representation of the set (“#<Set: {element1, element2, …}>”).

Returns a string representation of self:

Customer = Struct.new(:name, :address, :zip) # => Customer
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"

Returns a string representation of self (including the leading colon):

:foo.inspect # => ":foo"

Related: Symbol#to_s, Symbol#name.

Equivalent to sym.to_s.downcase.to_sym.

See String#downcase.

Related: Symbol#upcase.

The opposite of Pathname#absolute?

It returns false if the pathname begins with a slash.

p = Pathname.new('/im/sure')
p.relative?
    #=> false

p = Pathname.new('not/so/sure')
p.relative?
    #=> true

Returns the last access time for the file.

See File.atime.

Returns the birth time for the file. If the platform doesn’t have birthtime, raises NotImplementedError.

See File.birthtime.

Returns the last modified time of the file.

See File.mtime.

Update the access and modification times of the file.

See File.utime.

Update the access and modification times of the file.

Same as Pathname#utime, but does not follow symbolic links.

See File.lutime.

See FileTest.directory?.

See FileTest.sticky?.

Removes a file or directory, using File.unlink if self is a file, or Dir.unlink as necessary.

Search took: 9ms  ·  Total Results: 5313