Created
July 16, 2014 13:58
-
-
Save raghubetina/7d093f7d36926854946e to your computer and use it in GitHub Desktop.
Day 10 Warmup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following line will pull Rails' enhancements of Ruby's Date class into | |
# this script. | |
# You will then be able to use methods like Date.today, which returns an object | |
# representing today. | |
# You can also do things like Date.parse("1809-02-12") and it will return an | |
# object representing that date. | |
# You can then subtract one from the other to find the number of days between. | |
require 'active_support/core_ext/date/calculations' | |
class Person < Primate | |
attr_accessor :first_name | |
attr_accessor :last_name | |
attr_accessor :birthdate | |
def full_name | |
return "#{first_name} #{last_name}" | |
end | |
end | |
p = Person.new | |
p.first_name = "Raghu" | |
p.last_name = "Betina" | |
p.birthdate = "July 1st, 1982" | |
# The following doesn't currently work. | |
# Your job: make it work. Define the Person#age method. | |
# It should use the existing attributes to calculate a person's age. | |
puts "#{p.full_name} is #{p.age} years old." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment