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)
data.each do |key, val|
kls, index, *rem = key.to_s.split("-")
if rem.empty?
case kls
when "strip", "bus", "button"
target = send(kls)
else
when "vban"
dir = "#{index.chomp("stream")}stream"
index = rem[0]
target = vban.send(dir)
else
raise KeyError, "invalid config key '#{kls}'"
end
target[index.to_i].apply(val)
end