Skip to content

Instantly share code, notes, and snippets.

@RLGGHC
Created October 28, 2009 03:53
Show Gist options
  • Save RLGGHC/220218 to your computer and use it in GitHub Desktop.
Save RLGGHC/220218 to your computer and use it in GitHub Desktop.
BasicObject example
# 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