module Commands::Start
Public Class Methods
included(thor)
click to toggle source
# File lib/commands/start.rb, line 3 def self.included(thor) thor.class_eval do desc "start [NAME]", "Start new timer" def start(name) log = Log.find_by(name: name) # not found if !log output do say "#{name} not found", :red end exit end # already active? if log.active? output do say "#{name} already active", :red end exit end # begin new series, activate log if log.start! started_at = time_display(Time.now) output do say "#{name} started at #{started_at}", :green end else output do say "#{name} failed to start", :red end end end end end
Public Instance Methods
start(name)
click to toggle source
# File lib/commands/start.rb, line 6 def start(name) log = Log.find_by(name: name) # not found if !log output do say "#{name} not found", :red end exit end # already active? if log.active? output do say "#{name} already active", :red end exit end # begin new series, activate log if log.start! started_at = time_display(Time.now) output do say "#{name} started at #{started_at}", :green end else output do say "#{name} failed to start", :red end end end