Created
October 28, 2009 03:53
-
-
Save RLGGHC/220218 to your computer and use it in GitHub Desktop.
BasicObject example
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
# Courtesy David Black | |
class TinyXML < BasicObject | |
def method_missing(m, *args, &block) | |
$stdout << "<#{m}>\n" | |
if block | |
$stdout << yield | |
end | |
$stdout << "\n</#{m}>" | |
return | |
end | |
end | |
tx = TinyXML.new | |
tx.people do | |
tx.person do | |
tx.name do | |
"David" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment