Created
March 13, 2011 04:47
-
-
Save ahastudio/867873 to your computer and use it in GitHub Desktop.
#PNA2011 Ruby DSL example
This file contains hidden or 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
$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