Results for: "match"

if /foo/ then end

^^^^^

MatchData encapsulates the result of matching a Regexp against string. It is returned by Regexp#match and String#match, and also stored in a global variable returned by Regexp.last_match.

Usage:

url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html'
m = url.match(/(\d\.?)+/)   # => #<MatchData "2.5.0" 1:"0">
m.string                    # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html"
m.regexp                    # => /(\d\.?)+/
# entire matched substring:
m[0]                        # => "2.5.0"

# Working with unnamed captures
m = url.match(%r{([^/]+)/([^/]+)\.html$})
m.captures                  # => ["2.5.0", "MatchData"]
m[1]                        # => "2.5.0"
m.values_at(1, 2)           # => ["2.5.0", "MatchData"]

# Working with named captures
m = url.match(%r{(?<version>[^/]+)/(?<module>[^/]+)\.html$})
m.captures                  # => ["2.5.0", "MatchData"]
m.named_captures            # => {"version"=>"2.5.0", "module"=>"MatchData"}
m[:version]                 # => "2.5.0"
m.values_at(:version, :module)
                            # => ["2.5.0", "MatchData"]
# Numerical indexes are working, too
m[1]                        # => "2.5.0"
m.values_at(1, 2)           # => ["2.5.0", "MatchData"]

Global variables equivalence

Parts of last MatchData (returned by Regexp.last_match) are also aliased as global variables:

See also “Special global variables” section in Regexp documentation.

foo in bar ^^^^^^^^^^

foo in bar ^^^^^^^^^^

if /foo #{bar}/ then end

^^^^^^^^^^^^

case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^

foo => bar ^^^^^^^^^^

/(?<foo>foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^

case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^

foo => bar ^^^^^^^^^^

/(?<foo>foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^

No documentation available

if /foo/ then end

^^^^^

if /foo/ then end

^^^^^

if /foo #{bar}/ then end

^^^^^^^^^^^^

if /foo #{bar}/ then end

^^^^^^^^^^^^
No documentation available
No documentation available

Raised when attempting to convert special float values (in particular Infinity or NaN) to numerical classes which don’t support them.

Float::INFINITY.to_r   #=> FloatDomainError: Infinity

The Benchmark module provides methods to measure and report the time used to execute Ruby code.

The result:

              user     system      total        real
for:      1.010000   0.000000   1.010000 (  1.015688)
times:    1.000000   0.000000   1.000000 (  1.003611)
upto:     1.030000   0.000000   1.030000 (  1.028098)

mkmf.rb is used by Ruby C extensions to generate a Makefile which will correctly compile and link the C extension to Ruby and a third-party library.

Module Math provides methods for basic trigonometric, logarithmic, and transcendental functions, and for extracting roots.

You can write its constants and method calls thus:

Math::PI      # => 3.141592653589793
Math::E       # => 2.718281828459045
Math.sin(0.0) # => 0.0
Math.cos(0.0) # => 1.0

If you include module Math, you can write simpler forms:

include Math
PI       # => 3.141592653589793
E        # => 2.718281828459045
sin(0.0) # => 0.0
cos(0.0) # => 1.0

For simplicity, the examples here assume:

include Math
INFINITY = Float::INFINITY

The domains and ranges for the methods are denoted by open or closed intervals, using, respectively, parentheses or square brackets:

Many values returned by Math methods are numerical approximations. This is because many such values are, in mathematics, of infinite precision, while in numerical computation the precision is finite.

Thus, in mathematics, cos(π/2) is exactly zero, but in our computation cos(PI/2) is a number very close to zero:

cos(PI/2) # => 6.123031769111886e-17

For very large and very small returned values, we have added formatted numbers for clarity:

tan(PI/2)  # => 1.633123935319537e+16   # 16331239353195370.0
tan(PI)    # => -1.2246467991473532e-16 # -0.0000000000000001

See class Float for the constants that affect Ruby’s floating-point arithmetic.

What’s Here

Trigonometric Functions

Inverse Trigonometric Functions

Hyperbolic Trigonometric Functions

Inverse Hyperbolic Trigonometric Functions

Exponentiation and Logarithmic Functions

Fraction and Exponent Functions

Root Functions

Error Functions

Gamma Functions

Hypotenuse Function

No documentation available

Generated when trying to lookup a gem to indicate that the gem was found, but that it isn’t usable on the current platform.

fetch and install read these and report them to the user to aid in figuring out why a gem couldn’t be installed.

Raised when a gem dependencies file specifies a ruby version that does not match the current version.

Search took: 7ms  ·  Total Results: 1903