Skip to content

Instantly share code, notes, and snippets.

@tonini
Created November 11, 2009 23:05
Show Gist options
  • Save tonini/232413 to your computer and use it in GitHub Desktop.
Save tonini/232413 to your computer and use it in GitHub Desktop.
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