Class: MetallumCli::Configuration
- Inherits:
-
Object
- Object
- MetallumCli::Configuration
- Defined in:
- lib/metallum-cli/configuration.rb
Constant Summary collapse
- CONFIG_FILE =
"#{ENV['HOME']}/.metallumcli"
Instance Attribute Summary collapse
-
#lang ⇒ Object
Returns the value of attribute lang.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#lang ⇒ Object
Returns the value of attribute lang.
4 5 6 |
# File 'lib/metallum-cli/configuration.rb', line 4 def lang @lang end |
Class Method Details
.instance ⇒ Object
12 13 14 |
# File 'lib/metallum-cli/configuration.rb', line 12 def self.instance @instance ||= File.exists?(CONFIG_FILE) ? load_yml() : new.tap(&:defaults) end |
.load_yml ⇒ Object
16 17 18 |
# File 'lib/metallum-cli/configuration.rb', line 16 def self.load_yml YAML.load_file(CONFIG_FILE) end |
.save ⇒ Object
20 21 22 |
# File 'lib/metallum-cli/configuration.rb', line 20 def self.save File.open(CONFIG_FILE, 'w+') { |f| f.write(instance.to_yaml) } end |
Instance Method Details
#defaults ⇒ Object
8 9 10 |
# File 'lib/metallum-cli/configuration.rb', line 8 def defaults self.lang ||= 'en' end |