Results for: "partition"

Returns the absolute value (magnitude) for self; see polar coordinates:

Complex.polar(-1, 0).abs # => 1.0

If self was created with rectangular coordinates, the returned value is computed, and may be inexact:

Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2.

Returns the argument (angle) for self in radians; see polar coordinates:

Complex.polar(3, Math::PI/2).arg  # => 1.57079632679489660

If self was created with rectangular coordinates, the returned value is computed, and may be inexact:

Complex.polar(1, 1.0/3).arg # => 0.33333333333333326

Returns the array [self.real, self.imag]:

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

See Rectangular Coordinates.

If self was created with polar coordinates, the returned value is computed, and may be inexact:

Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]

Complex#rectangular is an alias for Complex#rect.

Returns the array [self.abs, self.arg]:

Complex.polar(1, 2).polar # => [1.0, 2.0]

See Polar Coordinates.

If self was created with rectangular coordinates, the returned value is computed, and may be inexact:

Complex.rect(1, 1).polar # => [1.4142135623730951, 0.7853981633974483]

Returns the conjugate of self, Complex.rect(self.imag, self.real):

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

Returns the conjugate of self, Complex.rect(self.imag, self.real):

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

Returns true if both self.real.finite? and self.imag.finite? are true, false otherwise:

Complex.rect(1, 1).finite?               # => true
Complex.rect(Float::INFINITY, 0).finite? # => false

Related: Numeric#finite?, Float#finite?.

Returns 1 if either self.real.infinite? or self.imag.infinite? is true, nil otherwise:

Complex.rect(Float::INFINITY, 0).infinite? # => 1
Complex.rect(1, 1).infinite?               # => nil

Related: Numeric#infinite?, Float#infinite?.

Returns zero if self is positive, Math::PI otherwise.

Returns array [self, 0].

Returns array [self.abs, self.arg].

Returns self.

Raises an exception if the value for freeze is neither true nor nil.

Related: Numeric#dup.

Returns the absolute value of self.

12.abs        #=> 12
(-34.56).abs  #=> 34.56
-34.56.abs    #=> 34.56
Returns +self+ if +self+ is not a zero value, +nil+ otherwise;
uses method <tt>zero?</tt> for the evaluation.

The returned +self+ allows the method to be chained:

  a = %w[z Bb bB bb BB a aA Aa AA A]
  a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
  # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]

Of the Core and Standard Library classes,
Integer, Float, Rational, and Complex use this implementation.

Related: zero?

Returns true if self is a finite number, false otherwise.

Returns nil, -1, or 1 depending on whether self is finite, -Infinity, or +Infinity.

Returns zero.

Returns self.

No documentation available

Splits str into an array of tokens in the same way the UNIX Bourne shell does.

See Shellwords.shellsplit for details.

Extracts data from self.

If block is not given, forming objects that become the elements of a new array, and returns that array. Otherwise, yields each object.

See Packed Data.

Like String#unpack, but unpacks and returns only the first extracted object. See Packed Data.

Inserts the given other_string into self; returns self.

If the Integer index is positive, inserts other_string at offset index:

'foo'.insert(1, 'bar') # => "fbaroo"

If the Integer index is negative, counts backward from the end of self and inserts other_string at offset index+1 (that is, after self[index]):

'foo'.insert(-2, 'bar') # => "fobaro"

Removes the contents of self:

s = 'foo' # => "foo"
s.clear   # => ""

Returns a string containing the characters in self; the first character is upcased; the remaining characters are downcased:

s = 'hello World!' # => "hello World!"
s.capitalize       # => "Hello world!"

The casing may be affected by the given options; see Case Mapping.

Related: String#capitalize!.

Search took: 3ms  ·  Total Results: 4702