Results for: "Data"

Returns self.

Returns 1.

Returns the value as a rational. The optional argument eps is always ignored.

Returns a complex object which denotes the given rectangular form.

Complex.rectangular(1, 2)  #=> (1+2i)

Returns an array; [cmp.real, cmp.imag].

Complex(1, 2).rectangular  #=> [1, 2]

Returns the complex conjugate.

Complex(1, 2).conjugate  #=> (1-2i)

Returns the numerator.

    1   2       3+4i  <-  numerator
    - + -i  ->  ----
    2   3        6    <-  denominator

c = Complex('1/2+2/3i')  #=> ((1/2)+(2/3)*i)
n = c.numerator          #=> (3+4i)
d = c.denominator        #=> 6
n / d                    #=> ((1/2)+(2/3)*i)
Complex(Rational(n.real, d), Rational(n.imag, d))
                         #=> ((1/2)+(2/3)*i)

See denominator.

Returns the denominator (lcm of both denominator - real and imag).

See numerator.

Returns the value as a rational if possible (the imaginary part should be exactly zero).

Complex(1.0/3, 0).rationalize  #=> (1/3)
Complex(1, 0.0).rationalize    # RangeError
Complex(1, 2).rationalize      # RangeError

See to_r.

Returns zero as a rational. The optional argument eps is always ignored.

Returns an array; [num, 0].

Returns self.

Returns num truncated (toward zero) to a precision of ndigits decimal digits (default: 0).

Numeric implements this by converting its value to a Float and invoking Float#truncate.

Returns true if num is less than 0.

Returns the numerator.

Returns the denominator (always positive).

Returns a Matchdata object (or nil) based on self and the given pattern.

Note: also updates Regexp-related global variables.

With no block given, returns the computed matchdata:

'foo'.match('f') # => #<MatchData "f">
'foo'.match('o') # => #<MatchData "o">
'foo'.match('x') # => nil

If Integer argument offset is given, the search begins at index offset:

'foo'.match('f', 1) # => nil
'foo'.match('o', 1) # => #<MatchData "o">

With a block given, calls the block with the computed matchdata and returns the block’s return value:

'foo'.match(/o/) {|matchdata| matchdata } # => #<MatchData "o">
'foo'.match(/x/) {|matchdata| matchdata } # => nil
'foo'.match(/f/, 1) {|matchdata| matchdata } # => nil

Returns true or false based on whether a match is found for self and pattern.

Note: does not update Regexp-related global variables.

Computes regexp by converting pattern (if not already a Regexp).

regexp = Regexp.new(pattern)

Returns true if self+.match(regexp) returns a Matchdata object, false otherwise:

'foo'.match?(/o/) # => true
'foo'.match?('o') # => true
'foo'.match?(/x/) # => false

If Integer argument offset is given, the search begins at index offset:

'foo'.match?('f', 1) # => false
'foo'.match?('o', 1) # => true

Returns a copy of str with the first character converted to uppercase and the remainder to lowercase.

See String#downcase for meaning of options and use with different encodings.

"hello".capitalize    #=> "Hello"
"HELLO".capitalize    #=> "Hello"
"123ABC".capitalize   #=> "123abc"

Modifies str by converting the first character to uppercase and the remainder to lowercase. Returns nil if no changes are made. There is an exception for modern Georgian (mkhedruli/MTAVRULI), where the result is the same as for String#downcase, to avoid mixed case.

See String#downcase for meaning of options and use with different encodings.

a = "hello"
a.capitalize!   #=> "Hello"
a               #=> "Hello"
a.capitalize!   #=> nil

Concatenates each object in objects to self and returns self:

s = 'foo'
s.concat('bar', 'baz') # => "foobarbaz"
s                      # => "foobarbaz"

For each given object object that is an Integer, the value is considered a codepoint and converted to a character before concatenation:

s = 'foo'
s.concat(32, 'bar', 32, 'baz') # => "foo bar baz"

Related: String#<<, which takes a single argument.

Returns float truncated (toward zero) to 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 floating point number when ndigits is positive, otherwise returns an integer.

2.8.truncate           #=> 2
(-2.8).truncate        #=> -2
1.234567.truncate(2)   #=> 1.23
34567.89.truncate(-2)  #=> 34500

Note that the limited precision of floating point arithmetic might lead to surprising results:

(0.3 / 0.1).truncate  #=> 2 (!)

Returns true if float is less than 0.

Returns the numerator. The result is machine dependent.

n = 0.3.numerator    #=> 5404319552844595
d = 0.3.denominator  #=> 18014398509481984
n.fdiv(d)            #=> 0.3

See also Float#denominator.

Returns the denominator (always positive). The result is machine dependent.

See also Float#numerator.

Search took: 4ms  ·  Total Results: 1361