use case in for steps

This commit is contained in:
onyx-and-iris 2023-07-25 08:17:51 +01:00
parent a05cf510f7
commit 4f08ed836b

View File

@ -17,23 +17,23 @@ module Voicemeeter
module Builder module Builder
private private
def steps def steps(step)
{ case step
strip: -> { (0...kind.num_strip).map { Strip::Strip.make(self, _1) } }, in :strip then -> { (0...kind.num_strip).map { Strip::Strip.make(self, _1) } }
bus: -> { (0...kind.num_bus).map { Bus::Bus.make(self, _1) } }, in :bus then -> { (0...kind.num_bus).map { Bus::Bus.make(self, _1) } }
button: -> { (0...kind.num_buttons).map { Button::Button.new(self, _1) } }, in :button then -> { (0...kind.num_buttons).map { Button::Button.new(self, _1) } }
vban: -> { Vban::Vban.new(self) }, in :vban then -> { Vban::Vban.new(self) }
command: -> { Command.new(self) }, in :command then -> { Command.new(self) }
recorder: -> { Recorder::Recorder.new(self) }, in :recorder then -> { Recorder::Recorder.new(self) }
device: -> { Device.new(self) }, in :device then -> { Device.new(self) }
fx: -> { Fx.new(self) }, in :fx then -> { Fx.new(self) }
patch: -> { Patch::Patch.new(self) }, in :patch then -> { Patch::Patch.new(self) }
option: -> { Option::Option.new(self) } in :option then -> { Option::Option.new(self) }
} end
end end
def director def director
[:strip, :bus, :button, :vban, :command, :device, :option] %i[strip bus button vban command device option]
end end
end end
@ -46,9 +46,7 @@ module Voicemeeter
def initialize(kind, **) def initialize(kind, **)
super super
steps.select { |k, v| director.include? k }.each do |k, v| director.each { |step| send("#{step}=", steps(step).call) }
send("#{k}=", v.call)
end
end end
def configs def configs