Skip to content

Instantly share code, notes, and snippets.

View ahastudio's full-sized avatar

Ashal aka JOKER ahastudio

View GitHub Profile
@ahastudio
ahastudio / lottery.rb
Created March 13, 2011 07:15
#PNA2011 추첨 프로그램 (Shoes 사용)
require "csv"
class Lottery
def initialize
filename = File.expand_path(File.dirname(__FILE__) + '/data.csv')
@names = CSV.read(filename)[1..-1].map{|row| row[0]}
end
def random
@names[rand(@names.size)]
@ahastudio
ahastudio / fake_web_dsl.rb
Created March 13, 2011 04:52
#PNA2011 Ruby DSL example
def application(name, &block)
$app = Application.new
$app.name = name
$app.instance_eval(&block)
end
class Application
attr_accessor :name
def initialize
@ahastudio
ahastudio / simple_rpg_dsl.rb
Created March 13, 2011 04:47
#PNA2011 Ruby DSL example
$npcs = {}
def say(words)
puts words
end
def npc(name, &block)
$npcs[name] = block
end