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
|
# File 'lib/gtk3/stock.rb', line 21
def add(stock_id, label, *rest)
case rest.size
when 0
options = {}
when 1
if rest[0].is_a?(Hash)
options = rest[0]
else
options = {:modifier => rest[0]}
end
else
options = {
:modifier => rest[0],
:key_value => rest[1],
:translation_domain => rest[2],
}
end
item = StockItem.new
stock_id = stock_id.to_s if stock_id.is_a?(Symbol)
item.stock_id = stock_id
item.label = label
modifier = options[:modifier]
item.modifier = modifier if modifier
key_value = options[:key_value]
item.keyval = key_value if key_value
translation_domain = options[:translation_domain]
item.translation_domain = translation_domain if translation_domain
add_raw([item])
end
|