Class: ActiveWindow::DotFile

Inherits:
Hash
  • Object
show all
Defined in:
lib/active_window/dot_file.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.filenameObject



25
26
27
# File 'lib/active_window/dot_file.rb', line 25

def self.filename
  File.join ENV['HOME'], ".#{PROGRAM_NAME}.yml"
end

.read(fname = nil) ⇒ Object



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

def self.read(fname=nil)
  fname ||= filename
  unless File.exists? fname
    new.save(fname)
  end
  YAML.load_file( fname )
end

Instance Method Details

#save(fname = nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/active_window/dot_file.rb', line 18

def save(fname=nil)
  fname ||= self.class.filename
  File.open( fname, 'w+' ) do |out|
    YAML.dump( self, out )
  end
end