From 06795329ccb217774236ba5ded55978b27f3f77d Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 14 Jul 2023 01:46:46 +0100 Subject: [PATCH] use maps to create higher class variables --- lib/voicemeeter/remote.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/voicemeeter/remote.rb b/lib/voicemeeter/remote.rb index df57f8c..378b54f 100644 --- a/lib/voicemeeter/remote.rb +++ b/lib/voicemeeter/remote.rb @@ -16,23 +16,28 @@ module Voicemeeter def initialize(kind, **kwargs) super - @strip = [] - kind.num_strip.times { |i| @strip << Strip::Strip.make(self, i) } - @bus = [] - kind.num_strip.times { |i| @bus << Bus::Bus.make(self, i) } - @button = [] - kind.num_buttons.times { |i| @button << Button::Button.new(self, i) } + @strip = (0...kind.num_strip).map { |i| Strip::Strip.make(self, i) } + @bus = (0...kind.num_bus).map { |i| Bus::Bus.make(self, i) } + @button = (0...kind.num_buttons).map { |i| Button::Button.new(self, i) } @vban = Vban::Vban.new(self) end def configs - Configs.get(@kind.name) + Configs.get(kind.name) + end + + def run + login + + yield if block_given? + + logout end end public - def self.make(kind_id, **kwargs) + def self.new(kind_id, **kwargs) " Factory method for remotes