Use singleton in various classes

This commit is contained in:
Alex Ling
2020-05-04 16:18:16 +00:00
parent 09b297cd8e
commit 1bec9f0108
16 changed files with 178 additions and 117 deletions

View File

@@ -26,6 +26,16 @@ class Config
"manga_rename_rule" => "{title}",
}
@@singlet : Config?
def self.current
@@singlet.not_nil!
end
def set_current
@@singlet = self
end
def self.load(path : String?)
path = "~/.config/mango/config.yml" if path.nil?
cfg_path = File.expand_path path, home: true