Created
November 11, 2009 23:05
-
-
Save tonini/232413 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
james = "say it loud!" | |
#1 | |
def james.more | |
puts "#{self} I'm black and proud!" | |
end | |
#2 | |
class << james | |
def power | |
puts "#{self} Power to the people!" | |
end | |
end | |
#3 | |
singleton = class << james | |
def soul | |
puts "#{self} I'm the man with the plan" | |
end | |
self # singleton class object | |
end | |
puts (singleton.instance_methods - "james".methods) # more, power, soul | |
puts james # say it loud! | |
puts james.more # say it loud! I'm black and proud! | |
puts james.power # say it loud! Power to the people | |
puts james.soul # say it loud! I'm the man with the plan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment