Skip to content

Instantly share code, notes, and snippets.

@ahastudio
Created March 13, 2011 04:47
Show Gist options
  • Save ahastudio/867873 to your computer and use it in GitHub Desktop.
Save ahastudio/867873 to your computer and use it in GitHub Desktop.
#PNA2011 Ruby DSL example
$npcs = {}
def say(words)
puts words
end
def npc(name, &block)
$npcs[name] = block
end
def talk_with(name)
$npcs[name].call
end
#----
npc "oldman" do
say "hahaha"
end
npc "lady" do
say "hohoho"
end
#----
talk_with("lady")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment