we already know valid params

so we can set instance variabels dynamically
This commit is contained in:
onyx-and-iris 2023-07-27 21:54:53 +01:00
parent 54e255535f
commit 23ac1b670c
2 changed files with 5 additions and 6 deletions

View File

@ -609,7 +609,7 @@ p vm.event.get
### Remote class ### Remote class
#### Voicemeeter.remote #### Voicemeeter::Remote
You may pass the following optional keyword arguments: You may pass the following optional keyword arguments:

View File

@ -31,13 +31,12 @@ module Voicemeeter
attr_reader :pdirty, :mdirty, :midi, :ldirty 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 make_writer_methods :pdirty, :mdirty, :midi, :ldirty
self.pdirty = pdirty kwargs.each do |key, value|
self.mdirty = mdirty instance_variable_set("@#{key}", value || false)
self.midi = midi end
self.ldirty = ldirty
end end
def to_s def to_s