Class: GridCLI::YMLHash
- Inherits:
-
Hash
- Object
- Hash
- GridCLI::YMLHash
show all
- Defined in:
- lib/gridcli/ymlhash.rb
Instance Method Summary
collapse
Constructor Details
#initialize(fname) ⇒ YMLHash
Returns a new instance of YMLHash.
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/gridcli/ymlhash.rb', line 5
def initialize(fname)
@griddir = File.expand_path(File.join("~", ".grid"))
Dir.mkdir(@griddir) if not File.exists?(@griddir)
@conffile = File.join(@griddir, fname)
super
update default_config
File.exists?(@conffile) ? update(YAML.load_file(@conffile)) : save
end
|
Instance Method Details
#default_config ⇒ Object
19
20
21
|
# File 'lib/gridcli/ymlhash.rb', line 19
def default_config
{}
end
|
#save ⇒ Object
23
24
25
|
# File 'lib/gridcli/ymlhash.rb', line 23
def save
File.open(@conffile, 'w') { |f| YAML.dump(Hash.new.merge(self), f) }
end
|