2023-07-17 06:03:37 +01:00
|
|
|
module Voicemeeter
|
|
|
|
module Util
|
2023-07-17 14:13:08 +01:00
|
|
|
module String
|
2023-07-27 10:58:26 +01:00
|
|
|
def snakecase(s)
|
|
|
|
s.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
2023-07-17 14:13:08 +01:00
|
|
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
|
|
.tr("-", "_")
|
|
|
|
.gsub(/\s/, "_")
|
|
|
|
.gsub(/__+/, "_")
|
|
|
|
.downcase
|
|
|
|
end
|
|
|
|
|
2023-07-27 10:58:26 +01:00
|
|
|
def camelcase(s)
|
|
|
|
s if s !~ /_/ && s =~ /[A-Z]+.*/
|
|
|
|
s.split("_").map { |e| e.capitalize }.join
|
2023-07-17 14:13:08 +01:00
|
|
|
end
|
2023-07-17 06:03:37 +01:00
|
|
|
|
2023-07-17 14:13:08 +01:00
|
|
|
module_function :snakecase, :camelcase
|
2023-07-17 06:03:37 +01:00
|
|
|
end
|
|
|
|
|
2023-07-17 14:13:08 +01:00
|
|
|
module Cache
|
2023-07-26 14:12:47 +01:00
|
|
|
def get(name, is_string = false)
|
|
|
|
return cache.delete(name) if cache.key? name
|
2023-07-17 14:13:08 +01:00
|
|
|
clear_dirty if @sync
|
2023-07-26 14:12:47 +01:00
|
|
|
super
|
|
|
|
end
|
2023-07-17 14:13:08 +01:00
|
|
|
|
2023-07-26 14:12:47 +01:00
|
|
|
def get_buttonstatus(id, mode)
|
|
|
|
return cache.delete("mb_#{id}_#{mode}") if cache.key? "mb_#{id}_#{mode}"
|
|
|
|
clear_dirty if @sync
|
|
|
|
super
|
2023-07-17 14:13:08 +01:00
|
|
|
end
|
|
|
|
end
|
2023-07-17 06:03:37 +01:00
|
|
|
end
|
|
|
|
end
|