Class: Numeric
Instance Method Summary collapse
-
#negative! ⇒ Numeric?
If this number is negative (i.e. < 0), returns itself, otherwise returns
nil. -
#negative? ⇒ Boolean
Returns
trueif this number is negative (i.e. < 0),falseotherwise. -
#nonnegative! ⇒ Numeric?
If this number is nonnegative (i.e. >= 0), returns itself, otherwise returns
nil. -
#nonnegative? ⇒ Boolean
Returns
trueif this number is nonnegative (i.e. >= 0),falseotherwise. -
#nonpositive! ⇒ Numeric?
If this number is nonpositive (i.e. <= 0), returns itself, otherwise returns
nil. -
#nonpositive? ⇒ Boolean
Returns
trueif this number is nonpositive (i.e. <= 0),falseotherwise. -
#positive! ⇒ Numeric?
If this number is positive (i.e. > 0), returns itself, otherwise returns
nil. -
#positive? ⇒ Boolean
Returns
trueif this number is positive (i.e. > 0),falseotherwise. -
#to_b ⇒ Boolean
Converts num to a boolean.
Instance Method Details
#negative! ⇒ Numeric?
If this number is negative (i.e. < 0), returns itself, otherwise returns nil.
65 66 67 |
# File 'lib/mug/negativity.rb', line 65 def negative! self < 0 ? self : nil end |
#negative? ⇒ Boolean
Returns true if this number is negative (i.e. < 0), false otherwise.
13 14 15 |
# File 'lib/mug/negativity.rb', line 13 def negative? self < 0 end |
#nonnegative! ⇒ Numeric?
If this number is nonnegative (i.e. >= 0), returns itself, otherwise returns nil.
91 92 93 |
# File 'lib/mug/negativity.rb', line 91 def nonnegative! self >= 0 ? self : nil end |
#nonnegative? ⇒ Boolean
Returns true if this number is nonnegative (i.e. >= 0), false otherwise.
39 40 41 |
# File 'lib/mug/negativity.rb', line 39 def nonnegative? self >= 0 end |
#nonpositive! ⇒ Numeric?
If this number is nonpositive (i.e. <= 0), returns itself, otherwise returns nil.
104 105 106 |
# File 'lib/mug/negativity.rb', line 104 def nonpositive! self <= 0 ? self : nil end |
#nonpositive? ⇒ Boolean
Returns true if this number is nonpositive (i.e. <= 0), false otherwise.
52 53 54 |
# File 'lib/mug/negativity.rb', line 52 def nonpositive? self <= 0 end |
#positive! ⇒ Numeric?
If this number is positive (i.e. > 0), returns itself, otherwise returns nil.
78 79 80 |
# File 'lib/mug/negativity.rb', line 78 def positive! self > 0 ? self : nil end |
#positive? ⇒ Boolean
Returns true if this number is positive (i.e. > 0), false otherwise.
26 27 28 |
# File 'lib/mug/negativity.rb', line 26 def positive? self > 0 end |
#to_b ⇒ Boolean
Converts num to a boolean. Returns true if not zero.
75 76 77 |
# File 'lib/mug/bool.rb', line 75 def to_b !self.zero? end |