Created
August 14, 2012 22:14
-
-
Save phaedryx/3353490 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
module Debug | |
def whoAmI? | |
"#{self.type.name} (\##{self.id}): #{self.to_s}" | |
end | |
end | |
class Phonograph | |
include Debug | |
def initialize(title) | |
@title = title | |
end | |
def type | |
self.class | |
end | |
def id | |
self.object_id | |
end | |
def to_s | |
@title | |
end | |
end | |
class EightTrack | |
include Debug | |
def initialize(title) | |
@title = title | |
end | |
def type | |
self.class | |
end | |
def id | |
self.object_id | |
end | |
def to_s | |
@title | |
end | |
end | |
ph = Phonograph.new("West End Blues") | |
et = EightTrack.new("Surrealistic Pillow") | |
ph.whoAmI? | |
et.whoAmI? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment