Skip to content

Instantly share code, notes, and snippets.

@xander-miller
Created October 20, 2014 20:39
Show Gist options
  • Select an option

  • Save xander-miller/1a68215e2d9a5b4e9101 to your computer and use it in GitHub Desktop.

Select an option

Save xander-miller/1a68215e2d9a5b4e9101 to your computer and use it in GitHub Desktop.
class President
attr_accessor :name, :age
def initialize(name, age)
@name, @age = name, age
end
def citizenship
self.class.citizenship
end
end
class UnitedStatesPresident < President
def self.citizenship
"The United States of America"
end
end
class FrancePresident < President
def self.citizenship
"La France"
end
def age
"#{super}, #{catchphrase}"
end
def name
"#{super}, #{catchphrase}"
end
def citizenship
"#{super}, #{catchphrase}"
end
def catchphrase
"bien sur"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment