-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.rb
90 lines (88 loc) · 2.43 KB
/
run.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
require File.join(Dir.pwd, 'rubybooty')
include Rubybooty
Shoes.app(title: 'LVRUG Rubybooty', width: 760) do
@entrants = {}
@checks = {}
@names_list = []
@para_list = []
i = 0
flow width: "100%", margin: ["0px", "0px", "0px", "10%"] do
background '#8D0000'..'#000000', curve: 12
banner "RubyBooty", align: "center", stroke: white
end
stack width: "60%" do
flow do
para "Entrants name: "
@name = edit_line
end
flow do
para "Number of entries: "
@entries = edit_line(width: 50)
end
button "Add" do
@entrants[@name.text] = @entries.text.to_i
@name_list.append do
@para_list.push << flow do
para "#{@name.text} is in for $#{@entrants[@name.text]}"
inscription "Delete?"
@check = check
end
@names_list << @name.text
@check.click do |c|
if c.checked? and confirm('Are you sure?')
val = @checks.values_at(c).first
@entrants.delete_if { |k,v| k.eql?(@names_list[val]) }
@para_list[val].remove
@sum = @entrants.values.inject(0, &:+)
@total.text = "Total: $#{@sum}"
end
c.checked = false
end
@checks[@check] = i
i += 1
end
@sum = @entrants.values.inject(0, &:+)
@total.text = "Total: $#{@sum}"
@name.text = ""
@entries.text = ""
end
end
stack width: "40%" do
stack do
background white
border black, strokewidth: 1
@name_list = stack
end
stack do
@total = para "Total: $0"
end
end
stack width: "100%" do
button "Run now!" do
winner = Rubybooty.raffle_sort(@entrants)
if winner
@results.append do
@title = para
@title.style(font: "Arial 40px", stroke: red)
@title.text = "and the winner is"
@anim = animate(30) do |a|
@title.text += "."
if a >= 40
@title.text = "#{winner} for $#{(@sum / 2.0).ceil}! AARRR!"
@anim.stop
end
end
end
else
alert "No winner. :("
end
end
@results = stack
end
flow width: "100%", margin: ["0px", "10%", "0px", "0px"] do
background '#CACACA'
stack top: 0, left: ((self.width - 120) / 2) do
image File.join(Dir.pwd, 'assets', 'lvrug.png'), width: 120, height: 63, click: "http://www.meetup.com/las-vegas-ruby-on-rails/"
end
end
end