Created
March 13, 2011 07:15
-
-
Save ahastudio/867947 to your computer and use it in GitHub Desktop.
#PNA2011 추첨 프로그램 (Shoes 사용)
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
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)] | |
end | |
def pop | |
name = @names[rand(@names.size)] | |
@names.delete(name) | |
name | |
end | |
end | |
Shoes.app :title => "PNA 2011" do | |
@lottery = Lottery.new | |
@pause = true | |
background black | |
stack :top => "20%" do | |
@paragraph = para "과연 누구?", :font => "AppleGothic", :size => 80, | |
:stroke => yellow, :align => "center" | |
end | |
keypress do | |
if @pause | |
@pause = false | |
else | |
@pause = true | |
@paragraph.text = @lottery.pop || "다 뽑았다~" | |
end | |
end | |
animate 100 do | |
unless @pause | |
@paragraph.text = @lottery.random || "다 뽑았다~" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment