Skip to content

Instantly share code, notes, and snippets.

@phaedryx
Created August 14, 2012 22:14
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 phaedryx/3353490 to your computer and use it in GitHub Desktop.
Save phaedryx/3353490 to your computer and use it in GitHub Desktop.
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