From 2e69321aca294f2f07b99a33ed881cd69a0044f5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 16 Jul 2023 22:33:50 +0100 Subject: [PATCH] make register a private method --- lib/voicemeeter/base.rb | 4 ++-- lib/voicemeeter/cbindings.rb | 4 ++-- lib/voicemeeter/configs.rb | 16 +++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/voicemeeter/base.rb b/lib/voicemeeter/base.rb index ef42e52..ec27056 100644 --- a/lib/voicemeeter/base.rb +++ b/lib/voicemeeter/base.rb @@ -155,7 +155,7 @@ module Voicemeeter def get_num_devices(dir) unless %i[in out].include? dir - raise Errors::VMError.new("dir got: #{dir}, expected :in or :out") + raise Errors::VMError.new "dir got: #{dir}, expected :in or :out" end if dir == :in CBindings.call(:bind_input_get_device_number, exp: ->(x) { x >= 0 }) @@ -166,7 +166,7 @@ module Voicemeeter def get_device_description(index, dir) unless %i[in out].include? dir - raise Errors::VMError.new("dir got: #{dir}, expected :in or :out") + raise Errors::VMError.new "dir got: #{dir}, expected :in or :out" end ctype = FFI::MemoryPointer.new(:long, 1) cname = FFI::MemoryPointer.new(:string, 256, true) diff --git a/lib/voicemeeter/cbindings.rb b/lib/voicemeeter/cbindings.rb index a05e558..f1c3932 100644 --- a/lib/voicemeeter/cbindings.rb +++ b/lib/voicemeeter/cbindings.rb @@ -56,11 +56,11 @@ module Voicemeeter res = send(fn, *args) if exp.nil? unless ok.include?(res) - raise Errors::VMCAPIError.new(fn, res) + raise Errors::VMCAPIError.new fn, res end else unless exp.call(res) || ok.include?(res) - raise Errors::VMCAPIError.new(fn, res) + raise Errors::VMCAPIError.new fn, res end end res diff --git a/lib/voicemeeter/configs.rb b/lib/voicemeeter/configs.rb index 5f3f918..609c823 100644 --- a/lib/voicemeeter/configs.rb +++ b/lib/voicemeeter/configs.rb @@ -17,16 +17,16 @@ module Voicemeeter def initialize(kind) @kind = kind @configs = Hash.new do |hash, key| - raise Errors::VMError.new("unknown config #{key}. known configs: #{hash.keys}") + raise Errors::VMError.new "unknown config #{key}. known configs: #{hash.keys}" end - @reader = FileReader.new(self, kind) + @yml_reader = FileReader.new(self, kind) end def to_s "Loader #{@kind}" end - protected + private def build_reset_profile aouts = (0...@kind.phys_out).to_h { |i| ["A#{i + 1}".to_sym, false] } @@ -44,7 +44,7 @@ module Voicemeeter phys_strip = (0...@kind.phys_in).to_h do |i| [ - "strip-#{i}", + "strip-#{i}".to_sym, {**aouts, **bouts, **strip_bools, **gain, **phys_float, **eq, **overrides} ] end @@ -54,7 +54,7 @@ module Voicemeeter virt_strip = (@kind.phys_in...@kind.phys_in + @kind.virt_in).to_h do |i| [ - "strip-#{i}", + "strip-#{i}".to_sym, {**aouts, **bouts, **strip_bools, **gain, **overrides} ] end @@ -62,13 +62,13 @@ module Voicemeeter bus_bools = %i[mute mono].to_h { |param| [param, false] } bus = (0...@kind.num_bus).to_h do |i| - ["bus-#{i}", {**bus_bools, **gain, **eq}] + ["bus-#{i}".to_sym, {**bus_bools, **gain, **eq}] end {**phys_strip, **virt_strip, **bus} end - def read_from_yml = @reader.read + def read_from_yml = @yml_reader.read public @@ -104,6 +104,8 @@ module Voicemeeter end end + private + def register(filepath) filename = (filepath.basename.sub_ext "").to_s.to_sym if @loader.configs.key? filename