mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-22 09:50:49 +00:00
the common interface
sits between higher and base classes
This commit is contained in:
parent
ceda486d91
commit
bd011a9497
37
lib/voicemeeter/iremote.rb
Normal file
37
lib/voicemeeter/iremote.rb
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
require_relative "errors"
|
||||||
|
|
||||||
|
module Voicemeeter
|
||||||
|
class IRemote
|
||||||
|
"
|
||||||
|
Common interface between base class and higher classes.
|
||||||
|
"
|
||||||
|
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)
|
||||||
|
@remote.get(_cmd(param), is_string)
|
||||||
|
end
|
||||||
|
|
||||||
|
def setter(param, value)
|
||||||
|
@remote.set(_cmd(param), value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def _cmd(param)
|
||||||
|
param.empty? ? "#{self.identifier}" : "#{self.identifier}.#{param}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def identifier
|
||||||
|
raise "Called abstract method: identifier"
|
||||||
|
end
|
||||||
|
|
||||||
|
def apply(params)
|
||||||
|
params.each { |key, val| self.send(key, val) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user