mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 15:00:46 +00:00
apply now handles nested hashes
some debug logging added
This commit is contained in:
parent
492a904a5f
commit
3e02f0c451
@ -1,10 +1,15 @@
|
||||
require_relative "errors"
|
||||
require_relative "meta"
|
||||
require "easy_logging"
|
||||
|
||||
module Voicemeeter
|
||||
class IRemote
|
||||
"
|
||||
Common interface between base class and higher classes.
|
||||
"
|
||||
include EasyLogging
|
||||
include Meta_Functions
|
||||
|
||||
def initialize(remote, i = nil)
|
||||
@remote = remote
|
||||
@index = i
|
||||
@ -15,15 +20,17 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def getter(param, is_string = false)
|
||||
logger.debug "getter: #{_cmd(param)}"
|
||||
@remote.get(_cmd(param), is_string)
|
||||
end
|
||||
|
||||
def setter(param, value)
|
||||
logger.debug "setter: #{_cmd(param)}=#{value}"
|
||||
@remote.set(_cmd(param), value)
|
||||
end
|
||||
|
||||
def _cmd(param)
|
||||
param.empty? ? "#{self.identifier}" : "#{self.identifier}.#{param}"
|
||||
param.empty? ? self.identifier : "#{self.identifier}.#{param}"
|
||||
end
|
||||
|
||||
def identifier
|
||||
@ -31,7 +38,18 @@ module Voicemeeter
|
||||
end
|
||||
|
||||
def apply(params)
|
||||
params.each { |key, val| self.send(key, val) }
|
||||
params.each do |key, val|
|
||||
if val.is_a? Hash
|
||||
target = self.send(key)
|
||||
target.apply(val)
|
||||
else
|
||||
self.send("#{key}=", val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
logger.debug "Unknown method #{method} for #{self}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user