2023-07-07 02:34:17 +01:00
|
|
|
module Voicemeeter
|
2023-07-14 12:01:41 +01:00
|
|
|
module MetaFunctions
|
2023-07-25 12:58:44 +01:00
|
|
|
private
|
|
|
|
|
2023-07-07 02:34:17 +01:00
|
|
|
# Accessor methods
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_accessor_bool(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param).to_i == 1 }
|
2023-07-14 00:56:16 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") do |value|
|
2023-07-14 00:56:16 +01:00
|
|
|
setter(param, value && 1 || 0)
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_accessor_string(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param, true) }
|
2023-07-07 02:34:17 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") { |value| setter(param, value) }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_accessor_int(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param).to_i }
|
2023-07-07 02:34:17 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") { |value| setter(param, value) }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_accessor_float(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param) }
|
2023-07-07 02:34:17 +01:00
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") { |value| setter(param, value) }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# reader methods
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_reader_string(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param, true) }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_reader_int(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { getter(param).to_i }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# writer methods
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_writer_bool(*params)
|
2023-07-14 17:07:56 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") do |value|
|
2023-07-14 17:07:56 +01:00
|
|
|
setter(param, value && 1 || 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_writer_string(*params)
|
2023-07-07 02:34:17 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method("#{param}=") { |value| setter(param, value) }
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|
2023-07-14 16:12:18 +01:00
|
|
|
|
|
|
|
# methods for performing certain actions as opposed to setting values
|
2023-08-30 12:27:50 +01:00
|
|
|
def attr_action_method(*params)
|
2023-07-14 16:12:18 +01:00
|
|
|
params.each do |param|
|
2023-08-30 12:27:50 +01:00
|
|
|
define_method(param) { setter(param, 1) }
|
2023-07-14 16:12:18 +01:00
|
|
|
end
|
|
|
|
end
|
2023-07-07 02:34:17 +01:00
|
|
|
end
|
|
|
|
end
|