mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 23:00:48 +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 "errors"
|
||||||
|
require_relative "meta"
|
||||||
|
require "easy_logging"
|
||||||
|
|
||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
class IRemote
|
class IRemote
|
||||||
"
|
"
|
||||||
Common interface between base class and higher classes.
|
Common interface between base class and higher classes.
|
||||||
"
|
"
|
||||||
|
include EasyLogging
|
||||||
|
include Meta_Functions
|
||||||
|
|
||||||
def initialize(remote, i = nil)
|
def initialize(remote, i = nil)
|
||||||
@remote = remote
|
@remote = remote
|
||||||
@index = i
|
@index = i
|
||||||
@ -15,15 +20,17 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def getter(param, is_string = false)
|
def getter(param, is_string = false)
|
||||||
|
logger.debug "getter: #{_cmd(param)}"
|
||||||
@remote.get(_cmd(param), is_string)
|
@remote.get(_cmd(param), is_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setter(param, value)
|
def setter(param, value)
|
||||||
|
logger.debug "setter: #{_cmd(param)}=#{value}"
|
||||||
@remote.set(_cmd(param), value)
|
@remote.set(_cmd(param), value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def _cmd(param)
|
def _cmd(param)
|
||||||
param.empty? ? "#{self.identifier}" : "#{self.identifier}.#{param}"
|
param.empty? ? self.identifier : "#{self.identifier}.#{param}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def identifier
|
def identifier
|
||||||
@ -31,7 +38,18 @@ module Voicemeeter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def apply(params)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user