raise a KeyError if the config key is invalid

This commit is contained in:
onyx-and-iris 2023-08-09 17:43:52 +01:00
parent 2a191dccb8
commit 2ca66a5925

View File

@ -220,12 +220,15 @@ module Voicemeeter
def apply(data) def apply(data)
data.each do |key, val| data.each do |key, val|
kls, index, *rem = key.to_s.split("-") kls, index, *rem = key.to_s.split("-")
if rem.empty? case kls
when "strip", "bus", "button"
target = send(kls) target = send(kls)
else when "vban"
dir = "#{index.chomp("stream")}stream" dir = "#{index.chomp("stream")}stream"
index = rem[0] index = rem[0]
target = vban.send(dir) target = vban.send(dir)
else
raise KeyError, "invalid config key '#{kls}'"
end end
target[index.to_i].apply(val) target[index.to_i].apply(val)
end end