Class: Numeric

Inherits:
Object show all
Defined in:
lib/hash-utils/numeric.rb

Overview

Numeric extension.

Since:

  • 0.16.0

Instance Method Summary collapse

Instance Method Details

#compare(number) ⇒ Object

Since:

  • 0.16.0



24
25
26
# File 'lib/hash-utils/numeric.rb', line 24

def compare(number)
    self <=> number
end

#negative!Object Also known as: negate!

Since:

  • 0.16.0



75
76
77
# File 'lib/hash-utils/numeric.rb', line 75

def negative!
    -self.positive!
end

#negative?Boolean Also known as: negative

Returns:

  • (Boolean)

Since:

  • 0.16.0



54
55
56
# File 'lib/hash-utils/numeric.rb', line 54

def negative?
    self < 0
end

#number?Boolean

Indicates, object is Numeric.

Returns:

  • (Boolean)

    true if yes, false in otherwise

Since:

  • 0.17.0



104
105
106
# File 'lib/hash-utils/numeric.rb', line 104

def number?
    true
end

#positive?Boolean Also known as: positive

Returns:

  • (Boolean)

Since:

  • 0.16.0



37
38
39
# File 'lib/hash-utils/numeric.rb', line 37

def positive?
    self > 0
end