Results for: "Data"

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 to an Integer.

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).

Converts pattern to a Regexp (if it isn’t already one), then invokes its match method on str. If the second parameter is present, it specifies the position in the string to begin the search.

'hello'.match('(.)\1')      #=> #<MatchData "ll" 1:"l">
'hello'.match('(.)\1')[0]   #=> "ll"
'hello'.match(/(.)\1/)[0]   #=> "ll"
'hello'.match('xx')         #=> nil

If a block is given, invoke the block with MatchData if match succeed, so that you can write

str.match(pat) {|m| ...}

instead of

if m = str.match(pat)
  ...
end

The return value is a value from block execution in this case.

Converts pattern to a Regexp (if it isn’t already one), then returns a true or false indicates whether the regexp is matched str or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search.

"Ruby".match?(/R.../)    #=> true
"Ruby".match?(/R.../, 1) #=> false
"Ruby".match?(/P.../)    #=> false
$&                       #=> nil

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.

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

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

Append—Concatenates the given object to str. If the object is an Integer, it is considered as a codepoint, and is converted to a character before concatenation. Concat can take multiple arguments. All the arguments are concatenated in order.

a = "hello "
a << "world"   #=> "hello world"
a.concat(33)   #=> "hello world!"
a              #=> "hello world!"

b = "sn"
b.concat(b, b)    #=> "snsnsn"

Truncates float to a given precision in decimal digits (default 0 digits).

Precision may be negative. Returns a floating point number when ndigits is more than zero.

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

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

See numerator.

Returns a simpler approximation of the value (flt-|eps| <= result <= flt+|eps|). if the optional eps is not given, it will be chosen automatically.

0.3.rationalize          #=> (3/10)
1.333.rationalize        #=> (1333/1000)
1.333.rationalize(0.01)  #=> (4/3)

See to_r.

Search took: 5ms  ·  Total Results: 1588