Skip to content

Instantly share code, notes, and snippets.

@max-power
Last active December 10, 2017 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-power/58317b8d7920e3ec436f6212debf6a1a to your computer and use it in GitHub Desktop.
Save max-power/58317b8d7920e3ec436f6212debf6a1a to your computer and use it in GitHub Desktop.
Ruby Age Calculation
class Age
def initialize(dob)
@dob = dob
end
def now
at Time.now
end
def at(date)
(f(date) - f(@dob)) / 10000
end
private
def f(date)
date.strftime('%Y%m%d').to_i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment