Class: Adroit::Age
- Inherits:
-
Object
- Object
- Adroit::Age
- Defined in:
- lib/adroit-age/api.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#dob ⇒ Object
Returns the value of attribute dob.
-
#now ⇒ Object
Returns the value of attribute now.
Instance Method Summary collapse
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
4 5 6 |
# File 'lib/adroit-age/api.rb', line 4 def age @age end |
#dob ⇒ Object
Returns the value of attribute dob.
4 5 6 |
# File 'lib/adroit-age/api.rb', line 4 def dob @dob end |
#now ⇒ Object
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 10 |
# File 'lib/adroit-age/api.rb', line 6 def find dob @dob = (dob.is_a? String) ? Date.parse(dob) : 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 |