module Commands::Stop
Public Class Methods
included(thor)
click to toggle source
# File lib/commands/stop.rb, line 3 def self.included(thor) thor.class_eval do desc "stop [NAME]", "Stop active timer" def stop(name) log = Log.find_by(name: name) # not found if !log output do say name.to_s + " not found", :red end exit end # log not active if log.inactive? output do say "#{name} not active", :red end exit end # stop log if log.stop! output do say "#{name} stopped!", :green time_total = log.total_time/3600 time_total = time_total.round(2) time_last = Series.find(log.series.last.id).total_time/3600 time_last = time_last.round(2) # time_start = say "#{time_last} hours out of #{time_total}", :cyan end else output do say "#{name} failed to stop", :red end end end end end
Public Instance Methods
stop(name)
click to toggle source
# File lib/commands/stop.rb, line 6 def stop(name) log = Log.find_by(name: name) # not found if !log output do say name.to_s + " not found", :red end exit end # log not active if log.inactive? output do say "#{name} not active", :red end exit end # stop log if log.stop! output do say "#{name} stopped!", :green time_total = log.total_time/3600 time_total = time_total.round(2) time_last = Series.find(log.series.last.id).total_time/3600 time_last = time_last.round(2) # time_start = say "#{time_last} hours out of #{time_total}", :cyan end else output do say "#{name} failed to stop", :red end end end