Class: Adroit::Age

Inherits:
Object
  • Object
show all
Defined in:
lib/adroit-age/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ageObject

Returns the value of attribute age.



4
5
6
# File 'lib/adroit-age/api.rb', line 4

def age
  @age
end

#dobObject

Returns the value of attribute dob.



4
5
6
# File 'lib/adroit-age/api.rb', line 4

def dob
  @dob
end

#nowObject

Returns the value of attribute now.



4
5
6
# File 'lib/adroit-age/api.rb', line 4

def now
  @now
end

Instance Method Details

#find(dob) ⇒ Object



6
7
8
9
# File 'lib/adroit-age/api.rb', line 6

def find dob
 		@now = Time.now.utc.to_date
 		@age = @now.year - dob.year - ((@now.month > dob.month || (@now.month == dob.month && @now.day >= dob.day)) ? 0 : 1)
end