Class: Numeric

Inherits:
Object show all
Defined in:
lib/transparent_nil/numeric.rb

Instance Method Summary collapse

Instance Method Details

#substract(other) ⇒ Numeric, NilClass

Nil-safe substraction. Returns nil if 0.

Returns:



25
26
27
28
# File 'lib/transparent_nil/numeric.rb', line 25

def substract(other)
  return nil if other.nil?
  self - other
end

#to_nil(*args) ⇒ Numeric, NilClass

Returns nil if 0.

Returns:



16
17
18
19
# File 'lib/transparent_nil/numeric.rb', line 16

def to_nil(*args)
  return nil  if self == 0
  self
end