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
|
# File 'lib/utility_belt/equipper.rb', line 26
def equip(*args)
return if args.empty?
gadgets_to_equip = []
if args[0].is_a?(Symbol) && [:all, :none, :defaults].include?(args[0])
what = args[0]
unless args[1].nil?
exceptions = args[1].has_key?(:except) ? args[1][:except] : []
exceptions = exceptions.to_s.to_a unless exceptions.is_a?( Array )
else
exceptions = []
end
case what
when :all
gadgets_to_equip.push(*(GADGETS - exceptions))
when :none
gadgets_to_equip.push(*exceptions)
when :defaults
gadgets_to_equip.push(*DEFAULTS)
end
else
args.each do |arg|
gadget = arg.to_s
gadgets_to_equip << gadget if GADGETS.include? gadget
end
end
gadgets_to_equip.each{|gadget| require "utility_belt/#{gadget}" }
@equipped ||= true
end
|