class GetToWork::ConfigFile

Attributes

data[R]

Public Class Methods

exist?() click to toggle source
# File lib/get_to_work/config_file.rb, line 37
def self.exist?
  File.exist? path
end
filename() click to toggle source
# File lib/get_to_work/config_file.rb, line 45
def self.filename
  ".get-to-work"
end
new() click to toggle source
# File lib/get_to_work/config_file.rb, line 9
def initialize
  setup_data(self.class.path)
end
path() click to toggle source
# File lib/get_to_work/config_file.rb, line 41
def self.path
  File.join(Dir.pwd, filename)
end
save() click to toggle source
# File lib/get_to_work/config_file.rb, line 29
def self.save
  instance.save
end

Public Instance Methods

[](key) click to toggle source
# File lib/get_to_work/config_file.rb, line 21
def [](key)
  @data[key]
end
[]=(key, value) click to toggle source
# File lib/get_to_work/config_file.rb, line 25
def []=(key, value)
  @data[key] = value
end
save() click to toggle source
# File lib/get_to_work/config_file.rb, line 33
def save
  File.open(self.class.path, "w") { |f| f.write YAML.dump(@data) }
end
setup_data(path) click to toggle source
# File lib/get_to_work/config_file.rb, line 13
def setup_data(path)
  @data = begin
            YAML.load_file(path)
          rescue Errno::ENOENT
            {}
          end
end