Last Updated: February 25, 2016
· blazeeboy

Calculate your age in years, days, hours, minutes, seconds in ruby

this script will calculate your age and make it update in front of your eyes :), this is a one scary script so be aware :D
first time i ran it i got panic , my age slipping second by second on a black screen with green text :)

require 'time'

Date_of_birth = '1988-8-31'

# Credit to :
# and modified a little bit
def humanize secs
    [60, :seconds], 
    [60, :minutes], 
    [24, :hours], 
    [365, :days], 
    [100, :years]
  ].map do |count, name|
    if secs > 0
      secs, n = secs.divmod(count)
      "#{n.to_i} #{name}"
  end.compact.reverse.join(' ')

loop do
    distance = - Time.parse(Date_of_birth)
    print humanize(distance)+"\r"
    sleep 1