Class: Tyme::Db
- Inherits:
-
Object
- Object
- Tyme::Db
- Defined in:
- lib/tyme/db.rb
Instance Method Summary collapse
- #add_entry(user, date, duration) ⇒ Object
-
#initialize(file = '/var/lib/tyme/db.yml') ⇒ Db
constructor
structure :user.
- #save ⇒ Object
Constructor Details
#initialize(file = '/var/lib/tyme/db.yml') ⇒ Db
structure :user
10 11 12 13 14 15 16 |
# File 'lib/tyme/db.rb', line 10 def initialize( file = '/var/lib/tyme/db.yml' ) # we check if directory exist, otherwise we create it dir = Pathname.new(file).dirname FileUtils.mkdir_p dir unless Dir.exist? dir @db_file = file @db = {} end |
Instance Method Details
#add_entry(user, date, duration) ⇒ Object
18 19 20 21 22 |
# File 'lib/tyme/db.rb', line 18 def add_entry(user,date,duration) load_db @db[user.to_sym] ||= {} @db[user.to_sym][date.to_sym] = duration end |
#save ⇒ Object
24 25 26 |
# File 'lib/tyme/db.rb', line 24 def save save_db end |