From 23ac1b670ceadcfa4a454cf17b2e377c88d0267c Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 27 Jul 2023 21:54:53 +0100 Subject: [PATCH] we already know valid params so we can set instance variabels dynamically --- README.md | 2 +- lib/voicemeeter/event.rb | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a35a4ae..2896d54 100644 --- a/README.md +++ b/README.md @@ -609,7 +609,7 @@ p vm.event.get ### Remote class -#### Voicemeeter.remote +#### Voicemeeter::Remote You may pass the following optional keyword arguments: diff --git a/lib/voicemeeter/event.rb b/lib/voicemeeter/event.rb index 9c48ca2..0046411 100644 --- a/lib/voicemeeter/event.rb +++ b/lib/voicemeeter/event.rb @@ -31,13 +31,12 @@ module Voicemeeter attr_reader :pdirty, :mdirty, :midi, :ldirty - def initialize(pdirty: false, mdirty: false, midi: false, ldirty: false) + def initialize(**kwargs) make_writer_methods :pdirty, :mdirty, :midi, :ldirty - self.pdirty = pdirty - self.mdirty = mdirty - self.midi = midi - self.ldirty = ldirty + kwargs.each do |key, value| + instance_variable_set("@#{key}", value || false) + end end def to_s