Created
June 9, 2013 09:05
-
-
Save domgetter/5742890 to your computer and use it in GitHub Desktop.
This file contains 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
#in child_class_test.rb | |
word = Word.new | |
#EOF child_class_test.rb | |
# in lib/word.rb | |
require_relative 'noun' | |
class Word | |
attr_reader :word, :part_of_speech, :definition, :etymology, :pronunciation | |
def initialize | |
@word = Noun.new | |
end | |
def to_s | |
@word.to_s | |
end | |
end | |
# EOF word.rb | |
# in lib/noun.rb | |
class Noun < Word | |
def initialize | |
@word = "cat" | |
@part_of_speech = :noun | |
end | |
end | |
# EOF noun.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment