Class: Expd::Config

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/expd/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
# File 'lib/expd/config.rb', line 10

def initialize(filename)
  @filename = filename
  @conf = {}
  load_from_file!
end

Class Method Details

.defaultsObject



29
30
31
# File 'lib/expd/config.rb', line 29

def self.defaults
  new File.expand_path("~/.expd_snippets")
end

Instance Method Details

#load_from_file!Object



16
17
18
19
# File 'lib/expd/config.rb', line 16

def load_from_file!
  @conf = YAML.load_file @filename if File.exist?(@filename)
  @conf[:snippets] ||= {}
end

#save!Object



21
22
23
# File 'lib/expd/config.rb', line 21

def save!
  File.open(@filename, "w") { |f| f.write YAML.dump(@conf) }
end

#snippetsObject



25
26
27
# File 'lib/expd/config.rb', line 25

def snippets
  self[:snippets]
end