syntax changes

This commit is contained in:
onyx-and-iris 2023-07-14 00:56:16 +01:00
parent 69901f3502
commit ca861bd1b8
2 changed files with 14 additions and 23 deletions

View File

@ -3,64 +3,55 @@ module Voicemeeter
# Accessor methods # Accessor methods
def make_accessor_bool(*params) def make_accessor_bool(*params)
params.each do |param| params.each do |param|
define_singleton_method(param) { self.getter(param).to_i == 1 } define_singleton_method(param) { getter(param).to_i == 1 }
define_singleton_method("#{param}=") do |value| define_singleton_method("#{param}=") do |value|
self.setter(param, value && 1 || 0) setter(param, value && 1 || 0)
end end
end end
end end
def make_accessor_string(*params) def make_accessor_string(*params)
params.each do |param| params.each do |param|
define_singleton_method(param) { self.getter(param, true) } define_singleton_method(param) { getter(param, true) }
define_singleton_method("#{param}=") do |value| define_singleton_method("#{param}=") { |value| setter(param, value) }
self.setter(param, value)
end
end end
end end
def make_accessor_int(*params) def make_accessor_int(*params)
params.each do |param| params.each do |param|
define_singleton_method("#{param}") do define_singleton_method(param) { getter(param).to_i }
return self.getter("#{param}").to_i
end
define_singleton_method("#{param}=") do |value| define_singleton_method("#{param}=") { |value| setter(param, value) }
self.setter("#{param}", value)
end
end end
end end
def make_accessor_float(*params) def make_accessor_float(*params)
params.each do |param| params.each do |param|
define_singleton_method(param) { self.getter(param) } define_singleton_method(param) { getter(param) }
define_singleton_method("#{param}=") do |value| define_singleton_method("#{param}=") { |value| setter(param, value) }
self.setter(param, value)
end
end end
end end
# reader methods # reader methods
def make_reader_string(*params) def make_reader_string(*params)
params.each do |param| params.each do |param|
define_singleton_method(param) { self.getter(param, true) } define_singleton_method(param) { getter(param, true) }
end end
end end
def make_reader_int(*params) def make_reader_int(*params)
params.each do |param| params.each do |param|
define_singleton_method(param) { self.getter(param).to_i } define_singleton_method(param) { getter(param).to_i }
end end
end end
# writer methods # writer methods
def make_writer_string(*params) def make_writer_string(*params)
params.each do |param| params.each do |param|
define_singleton_method("#{param}=") do |value| define_singleton_method("#{param}=") { |value| setter(param, value) }
self.setter(param, value)
end
end end
end end
end end

View File

@ -7,11 +7,11 @@ module Voicemeeter
end end
def get(key) def get(key)
@cache[key] cache[key]
end end
def set(key, velocity) def set(key, velocity)
@cache[key] = velocity cache[key] = velocity
end end
end end
end end