mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 01:40:49 +00:00
51 lines
1.0 KiB
Ruby
51 lines
1.0 KiB
Ruby
module Voicemeeter
|
|
# Common interface with the base Remote class.
|
|
module IRemote
|
|
include Logging
|
|
|
|
def initialize(remote, i = nil)
|
|
@remote = remote
|
|
@index = i
|
|
end
|
|
|
|
def to_s
|
|
"#{self.class.name.split("::").last}#{@index}#{@remote.kind}"
|
|
end
|
|
|
|
private
|
|
|
|
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? ? identifier : "#{identifier}.#{param}"
|
|
end
|
|
|
|
def identifier
|
|
raise "Called abstract method: identifier"
|
|
end
|
|
|
|
public
|
|
|
|
def apply(params)
|
|
params.each do |key, val|
|
|
if val.is_a? Hash
|
|
target = public_send(key)
|
|
target.apply(val)
|
|
elsif key == :mode
|
|
mode.public_send("#{val}=", true)
|
|
else
|
|
public_send("#{key}=", val)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|