Skip to content

Instantly share code, notes, and snippets.

@unfo
Last active December 19, 2015 09:28
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 unfo/5932751 to your computer and use it in GitHub Desktop.
Save unfo/5932751 to your computer and use it in GitHub Desktop.
require 'date'
class Human
attr_reader :name
attr_reader :dob
def initialize
@dob = Date.new
end
def christen(name)
@name = name
end
def change_name(name)
@name = name
end
def age
Date.new - @dob
end
def adult?
age > 18
end
def older_than?(other)
age > other.age
end
end
bob = Human.new
bob.christen('Bob')
bob.adult?
# => false
alice = Human.new
bob.older_than? alice
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment