module Timeless::Stopwatch
Constants
- START_FILENAME
Storing and retrieving start time and notes
file containing the start time
Public Class Methods
clocking?()
click to toggle source
# File lib/timeless/stopwatch.rb, line 37 def self.clocking? File.exists?(START_FILENAME) end
forget()
click to toggle source
forget the start clock
# File lib/timeless/stopwatch.rb, line 57 def self.forget File.delete(START_FILENAME) if File.exists?(START_FILENAME) end
get_start()
click to toggle source
# File lib/timeless/stopwatch.rb, line 41 def self.get_start if clocking? array = CSV.read(START_FILENAME, "r") [array[0][0], array[0][1]] else [nil, nil] end end
start(start=nil, notes=nil)
click to toggle source
# File lib/timeless/stopwatch.rb, line 8 def self.start start=nil, notes=nil store_start (start ? start : Time.now), (notes ? notes : "") end
stop(start=nil, stop=nil, notes=nil)
click to toggle source
# File lib/timeless/stopwatch.rb, line 12 def self.stop start=nil, stop=nil, notes=nil if not start start, _ = get_start end if notes == nil or notes == "" _, notes = get_start end if not stop stop = Time.now end forget # forget started clock, if any [start, stop, notes] end
store_start(start, notes)
click to toggle source
# File lib/timeless/stopwatch.rb, line 50 def self.store_start start, notes CSV.open(START_FILENAME, "w") do |csv| csv << [start, notes] end end