class Ptimelog::Command::Edit
edit one file. without argument, it will edit the timelog, otherwise a parser-script is loaded
Public Class Methods
new(file)
click to toggle source
Calls superclass method
Ptimelog::Command::Base::new
# File lib/ptimelog/command/edit.rb, line 8 def initialize(file) super() @scripts = Script.new(@config[:dir]) @file = file end
Public Instance Methods
run()
click to toggle source
# File lib/ptimelog/command/edit.rb, line 15 def run launch_editor(find_file(@file)) end
Private Instance Methods
empty_inferer(file)
click to toggle source
# File lib/ptimelog/command/edit.rb, line 49 def empty_inferer(file) [true, @scripts.inferer(file)] end
existing_inferer(file)
click to toggle source
# File lib/ptimelog/command/edit.rb, line 43 def existing_inferer(file) fn = @scripts.inferer(file) [fn.exist?, fn] end
find_file(requested_file)
click to toggle source
# File lib/ptimelog/command/edit.rb, line 27 def find_file(requested_file) %i[ timelog existing_inferer empty_inferer ].each do |file_lookup| valid, filename = send(file_lookup, requested_file) return filename if valid end end
launch_editor(file)
click to toggle source
# File lib/ptimelog/command/edit.rb, line 21 def launch_editor(file) editor = `which $EDITOR`.chomp exec "#{editor} #{file}" end
timelog(file)
click to toggle source
# File lib/ptimelog/command/edit.rb, line 39 def timelog(file) [file.nil?, Timelog.timelog_txt] end