Class: Omc::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/omc/config.rb

Constant Summary collapse

PATHS =
[
  File.join(ENV['HOME'], '.config', 'omcrc'),
  File.join(ENV['HOME'], '.omcrc'),
  '.omcrc'
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Config

Returns a new instance of Config.



23
24
25
# File 'lib/omc/config.rb', line 23

def initialize(config={})
  @config = config
end

Class Method Details

.loadObject



10
11
12
13
14
15
16
# File 'lib/omc/config.rb', line 10

def self.load
  config = new
  PATHS.each do |path|
    config.load_file(path)
  end
  config
end

Instance Method Details

#accountObject



27
28
29
# File 'lib/omc/config.rb', line 27

def 
  @config['account']
end

#load_file(path) ⇒ Object



18
19
20
21
# File 'lib/omc/config.rb', line 18

def load_file path
  return unless File.exists?(path)
  @config.update TOML.load_file(path)
end