Class: Numeric

Inherits:
Object show all
Defined in:
lib/multiarray.rb,
lib/multiarray/complex.rb,
lib/multiarray/rgb.rb

Overview

The Numeric class is extended with a few methods

Instance Method Summary collapse

Instance Method Details

#bNumeric

Get blue component

Returns:



900
901
902
# File 'lib/multiarray/rgb.rb', line 900

def b
  self
end

#conjNumeric

Compute complex conjugate

Returns:



690
691
692
# File 'lib/multiarray/complex.rb', line 690

def conj
  self
end

#gNumeric

Get green component

Returns:



893
894
895
# File 'lib/multiarray/rgb.rb', line 893

def g
  self
end

#major(other) ⇒ Numeric

Get larger number of two numbers

Parameters:

  • other (Numeric)

    The other number.

Returns:

  • (Numeric)

    The larger number of the two.



576
577
578
579
580
581
582
583
# File 'lib/multiarray.rb', line 576

def major( other )
  if other.is_a? Numeric
    ( self >= other ).conditional self, other
  else
    x, y = other.coerce self
    x.major other
  end
end

#minor(other) ⇒ Numeric

Get smaller number of two numbers

Parameters:

  • other (Numeric)

    The other number.

Returns:

  • (Numeric)

    The smaller number of the two.



590
591
592
593
594
595
596
597
# File 'lib/multiarray.rb', line 590

def minor( other )
  if other.is_a? Numeric
    ( self <= other ).conditional self, other
  else
    x, y = other.coerce self
    x.minor other
  end
end

#rNumeric

Get red component

Returns:



886
887
888
# File 'lib/multiarray/rgb.rb', line 886

def r
  self
end

#swap_rgbNumeric

Swap colour channels

Returns:



907
908
909
# File 'lib/multiarray/rgb.rb', line 907

def swap_rgb
  self
end