Class: Noir::Command::Edit::Note
Class Method Summary
collapse
sub_commands
check_command_not_found, description, sub_commands
Class Method Details
.edit(target) ⇒ Object
6
7
8
|
# File 'lib/noir/command/edit/note.rb', line 6
def edit target
system("#{Noir::Command::Edit.editor} #{target}")
end
|
.edit_before_note(diff) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/noir/command/edit/note.rb', line 26
def edit_before_note diff
notes = Dir.glob(Noir::Command::New::Note::FileNameGlob)
if notes.size > diff.abs.succ
edit notes.sort_by(&:to_i)[diff-1]
else
raise "Cannot find notes before #{diff} count."
end
end
|
.edit_today_note ⇒ Object
19
20
21
22
23
24
|
# File 'lib/noir/command/edit/note.rb', line 19
def edit_today_note
search_pattern = '*' + Time.now.strftime(Noir::Command::New::Note::TimeFormat) + '*'
today_files = Dir.glob(search_pattern)
target = today_files.sort.last || Noir::Command::New::Note.create_new_note
edit target
end
|
.execute(*args) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/noir/command/edit/note.rb', line 10
def execute *args
if args.size.zero?
edit_today_note
else
edit_before_note args.first.to_i
end
end
|