Sha256: f472872854b32c58289ba7b62c734b3c50f5b741a63d807ff741427194598f1a
Contents?: true
Size: 559 Bytes
Versions: 2
Compression:
Stored size: 559 Bytes
Contents
require 'yaml' module Tyme class Db # structure # :user def initialize( file = '/var/lib/tyme/db.yml' ) @db_file = file @db = {} end def add_entry(user,date,duration) load_db @db[user.to_sym] ||= {} @db[user.to_sym][date.to_sym] = duration end def save save_db end private def load_db @db = YAML.load_file(@db_file) if (@db.empty? && File.exist?(@db_file)) end def save_db File.open(@db_file, 'w') {|f| f.write @db.to_yaml } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tyme-0.1.2 | lib/tyme/db.rb |
tyme-0.1.0 | lib/tyme/db.rb |