In Files

  • mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
  • mrbgems/mruby-rational/mrblib/rational.rb
  • mrblib/numeric.rb

Numeric

Numeric

ISO 15.2.7

Public Instance Methods

+@() click to toggle source

Returns the receiver simply.

ISO 15.2.7.4.1

 
               # File mrblib/numeric.rb, line 11
def +@
  self
end
            
-@() click to toggle source

Returns the receiver's value, negated.

ISO 15.2.7.4.2

 
               # File mrblib/numeric.rb, line 19
def -@
  0 - self
end
            
abs() click to toggle source

Returns the absolute value of the receiver.

ISO 15.2.7.4.3

 
               # File mrblib/numeric.rb, line 27
def abs
  if self < 0
    -self
  else
    self
  end
end
            
negative?() click to toggle source
 
               # File mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb, line 18
def negative?
  self < 0
end
            
nonzero?() click to toggle source
 
               # File mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb, line 6
def nonzero?
  if self == 0
    nil
  else
    self
  end
end
            
positive?() click to toggle source
 
               # File mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb, line 14
def positive?
  self > 0
end
            
to_r() click to toggle source
 
               # File mrbgems/mruby-rational/mrblib/rational.rb, line 80
def to_r
  Rational(self, 1)
end
            
zero?() click to toggle source
 
               # File mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb, line 2
def zero?
  self == 0
end