Module: AgeCalculator

Defined in:
lib/age_calc.rb

Class Method Summary collapse

Class Method Details

.age_calc(birthday) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/age_calc.rb', line 3

def self.age_calc(birthday)
  years = Date.today.year - birthday.year
  if Date.today.month < birthday.month
    years -= 1
  elsif Date.today.month == birthday.month && Date.today.day < birthday.day
    years -= 1
  end
  years
end