2023-07-07 02:35:34 +01:00
|
|
|
require_relative "errors"
|
2023-07-09 05:49:08 +01:00
|
|
|
require_relative "meta"
|
|
|
|
require "easy_logging"
|
2023-07-07 02:35:34 +01:00
|
|
|
|
|
|
|
module Voicemeeter
|
|
|
|
class IRemote
|
2023-07-09 05:49:08 +01:00
|
|
|
include EasyLogging
|
2023-07-14 12:01:41 +01:00
|
|
|
include MetaFunctions
|
2023-07-09 05:49:08 +01:00
|
|
|
|
2023-07-07 02:35:34 +01:00
|
|
|
def initialize(remote, i = nil)
|
|
|
|
@remote = remote
|
|
|
|
@index = i
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
"#{self.class.name.split("::").last}#{@index}#{@remote.kind}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def getter(param, is_string = false)
|
2023-07-09 05:49:08 +01:00
|
|
|
logger.debug "getter: #{_cmd(param)}"
|
2023-07-07 02:35:34 +01:00
|
|
|
@remote.get(_cmd(param), is_string)
|
|
|
|
end
|
|
|
|
|
|
|
|
def setter(param, value)
|
2023-07-09 05:49:08 +01:00
|
|
|
logger.debug "setter: #{_cmd(param)}=#{value}"
|
2023-07-07 02:35:34 +01:00
|
|
|
@remote.set(_cmd(param), value)
|
|
|
|
end
|
|
|
|
|
|
|
|
def _cmd(param)
|
2023-07-14 01:47:36 +01:00
|
|
|
param.empty? ? identifier : "#{identifier}.#{param}"
|
2023-07-07 02:35:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
raise "Called abstract method: identifier"
|
|
|
|
end
|
|
|
|
|
|
|
|
def apply(params)
|
2023-07-09 05:49:08 +01:00
|
|
|
params.each do |key, val|
|
|
|
|
if val.is_a? Hash
|
2023-07-14 12:01:41 +01:00
|
|
|
target = send(key)
|
2023-07-09 05:49:08 +01:00
|
|
|
target.apply(val)
|
2023-07-14 12:01:41 +01:00
|
|
|
elsif key == :mode
|
|
|
|
mode.send("#{val}=", true)
|
2023-07-09 05:49:08 +01:00
|
|
|
else
|
2023-07-14 12:01:41 +01:00
|
|
|
send("#{key}=", val)
|
2023-07-09 05:49:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-07-07 02:35:34 +01:00
|
|
|
end
|
|
|
|
end
|