Class: Ig3tool::VendingMachineWindow
Constant Summary
collapse
["Automaat"]
- ICON =
"cola_xsmall.png"
- LEFTCOL =
[
[ "Coca Cola", "5449000000996" ],
[ "Coca Cola Light", "5449000050205" ],
[ "Coca Cola Zero", "5449000131805" ],
[ "Coca Light Lemon", "5449000089229" ],
[ "Fanta Orange", "5449000011527" ],
[ "Fanta Lemon", "5449000006004" ],
]
- RIGHTCOL =
[
[ "Minute Maid", "90494024" ],
[ "Minute Maid Tropical", "5449000100573" ],
[ "Minute Maid Appelsap", "90494031" ],
[ "Nestea", "5449000027382" ],
[ "Aquarius Orange", "5449000033819" ],
[ "Nalu", "5449000067456" ],
]
Constants inherited
from GladeHelper
GladeHelper::GLADE_DIR
Instance Method Summary
collapse
Methods inherited from GladeHelper
#_get_widget, #add_window_colorer, #load_sounds, #make_debugger_combo, #make_eval_widget, #make_status_combo, #play, #present, #show, #speak
Constructor Details
Returns a new instance of VendingMachineWindow.
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
|
# File 'lib/ui/automaatwindow.rb', line 25
def initialize
super("vendingmachine.glade")
@notification = @glade.get_widget("notification")
@entries = [ ]
[[LEFTCOL, @glade.get_widget("blikjes_table")],
[RIGHTCOL, @glade.get_widget("flesjes_table")]].
each do |list, table|
table.resize(list.length, 2)
list.each_with_index do |(name, barcode), i|
label = Gtk::Label.new(name + ":")
label.set_alignment(0, 0.5)
table.attach(label, 0, 1, i, i + 1)
entry = Gtk::Entry.new
entry.name = barcode
make_eval_widget entry
table.attach(entry, 1, 2, i, i + 1)
@entries <<= entry
end
end
@debuggers = @glade.get_widget("debuggers")
make_debugger_combo(@debuggers)
@window.show_all
end
|
Instance Method Details
#_print_msg(msg) ⇒ Object
95
96
97
98
|
# File 'lib/ui/automaatwindow.rb', line 95
def _print_msg(msg)
@notification.text = msg
puts msg
end
|
54
55
56
57
58
59
|
# File 'lib/ui/automaatwindow.rb', line 54
def number_eval_widget(widget, fallback)
super(widget, fallback)
@notification.text = ""
end
|
#sell_clicked ⇒ Object
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
91
92
93
|
# File 'lib/ui/automaatwindow.rb', line 61
def sell_clicked
if @debuggers.active_iter.nil?
_print_msg("Selecteer eerst uw naam uit de debugger-lijst!")
return
end
debugger = @debuggers.active_iter[0]
aantal = 0
items = {}
filled_entries = @entries.select {|x| !x.text.nil? and x.text.to_i > 0}
filled_entries.each do |entry|
items[entry.name] = entry.text.to_i
aantal += entry.text.to_i
end
if items.empty?
_print_msg("Minstens een element nodig om te verkopen!")
return
end
begin
total = $client.product_restock!( :debugger => debugger.username,
:items => items)
rescue Exception => e
_print_msg "Fout: Verkopen: #{$!}"
else
_print_msg "#{aantal} items verkocht, voor EUR #{total.from_c}!"
end
@entries.each { |entry| entry.text = "" }
end
|