class Numeric

Add blank? method to Numeric class.

Public Instance Methods

blank?() click to toggle source

Numerics are never blank

@example

0.blank?          # =>  false
1.blank?          # =>  false
6.54321.blank?    # =>  false

@return [FalseClass]

@api public

# File lib/garcon/core_ext/numeric.rb, line 32
def blank?
  false
end
clone?() click to toggle source
# File lib/garcon/core_ext/numeric.rb, line 43
def clone? ; false ; end
dup!() click to toggle source

Since Numeric is immutable it cannot be duplicated. For this reason try_dup returns self.

1.dup!  #=> 1
# File lib/garcon/core_ext/numeric.rb, line 41
def dup!   ; self  ; end
dup?() click to toggle source
# File lib/garcon/core_ext/numeric.rb, line 42
def dup?   ; false ; end
time_humanize(include_seconds = false) click to toggle source

Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.

@example

1.time_humanize(true)    -> 1 seconds
36561906.time_humanize   -> 1 years 2 months 3 days 4 hours 5 minutes
# File lib/garcon/core_ext/time.rb, line 214
def time_humanize(include_seconds = false)
  deta = self
  deta,  seconds = deta.divmod(60)
  deta,  minutes = deta.divmod(60)
  deta,  hours   = deta.divmod(24)
  deta,  days    = deta.divmod(30)
  years, months  = deta.divmod(12)

  ret  = ''
  ret << "#{years} years "     unless years   == 0
  ret << "#{months} months "   unless months  == 0
  ret << "#{days} days "       unless days    == 0
  ret << "#{hours} hours "     unless hours   == 0
  ret << "#{minutes} minutes " unless minutes == 0
  ret << "#{seconds} seconds"      if include_seconds

  ret.rstrip
end