From 917a5919563604c6a2c0416a6b8eb214b6328c1c Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 22 Jul 2023 16:44:24 +0100 Subject: [PATCH] use unless over if ! --- lib/voicemeeter/configs.rb | 2 +- lib/voicemeeter/event.rb | 4 ++-- lib/voicemeeter/recorder.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/voicemeeter/configs.rb b/lib/voicemeeter/configs.rb index 889804a..5d1da61 100644 --- a/lib/voicemeeter/configs.rb +++ b/lib/voicemeeter/configs.rb @@ -123,7 +123,7 @@ module Voicemeeter public def get(kind_id) - if @loaders.nil? + unless defined? @loaders @loaders = Kinds::ALL.to_h { |kind| [kind.name, Loader.new(kind)] } @loaders.each { |name, loader| loader.run } end diff --git a/lib/voicemeeter/event.rb b/lib/voicemeeter/event.rb index 0d61942..7c7eef5 100644 --- a/lib/voicemeeter/event.rb +++ b/lib/voicemeeter/event.rb @@ -81,12 +81,12 @@ module Voicemeeter end def add(events) - events = [events] if !events.respond_to? :each + events = [events] unless events.respond_to? :each events.each { |e| send("#{e}=", true) } end def remove(events) - events = [events] if !events.respond_to? :each + events = [events] unless events.respond_to? :each events.each { |e| send("#{e}=", false) } end end diff --git a/lib/voicemeeter/recorder.rb b/lib/voicemeeter/recorder.rb index db75cd8..316687f 100644 --- a/lib/voicemeeter/recorder.rb +++ b/lib/voicemeeter/recorder.rb @@ -39,7 +39,7 @@ module Voicemeeter end def goto(timestr) - if !(timestr =~ /^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/) + unless /^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/.match?(timestr) logger.error("goto got: '#{timestr}', but expects a time string in the format 'hh:mm:ss'") return end