class Pompom::Worklog
Public Class Methods
new(path)
click to toggle source
# File lib/pompom.rb, line 59 def initialize(path) @path = File.expand_path(path) @directory = File.dirname(@path) end
Public Instance Methods
finish_early()
click to toggle source
# File lib/pompom.rb, line 69 def finish_early @db[:pomodoros].where(:id => @id).update(:finished_early => true) end
start(pomodoro)
click to toggle source
# File lib/pompom.rb, line 64 def start(pomodoro) ensure_present @id = @db[:pomodoros].insert(:started_at => Time.now, :message => pomodoro.message, :finished_early => false) end
Private Instance Methods
ensure_present()
click to toggle source
# File lib/pompom.rb, line 75 def ensure_present if File.exists?(@path) @db = Sequel.sqlite(@path) else FileUtils.mkdir_p(@directory) unless File.exists?(@directory) @db = Sequel.sqlite(@path) @db.create_table :pomodoros do primary_key :id Time :started_at String :message TrueClass :finished_early end end end