Class: Work::Md::Commands::Tlast

Inherits:
Object
  • Object
show all
Defined in:
lib/work/md/commands/tlast.rb

Class Method Summary collapse

Class Method Details

.execute(_argv = []) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/work/md/commands/tlast.rb', line 8

def execute(_argv = [])
  last_date = Date.today.prev_day
  work_dir = Work::Md::Config.work_dir
  last_file_name = nil

  (1..160).each do
    last_file_name = "#{last_date.strftime('%Y/%m/%d')}.md"
    break if ::File.exist?("#{work_dir}/#{last_file_name}")

    last_date = last_date.prev_day
  end

  today_file_name = Work::Md::DateFile.create_if_not_exist(DateTime.now)

  Work::Md::File.open_in_editor([today_file_name, last_file_name].compact)
end