Class: Ptimelog::Command::Add

Inherits:
Base
  • Object
show all
Defined in:
lib/ptimelog/command/add.rb

Overview

add a new entrie with the current date and time

Instance Method Summary collapse

Methods inherited from Base

#entries=

Constructor Details

#initialize(task) ⇒ Add

Returns a new instance of Add.



9
10
11
12
13
14
15
# File 'lib/ptimelog/command/add.rb', line 9

def initialize(task)
  super()

  @task = task
  @timelog = Ptimelog::Timelog.instance
  @new_lines = []
end

Instance Method Details

#needs_entries?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ptimelog/command/add.rb', line 17

def needs_entries?
  false
end

#runObject



21
22
23
24
25
26
# File 'lib/ptimelog/command/add.rb', line 21

def run
  add_empty_line if @timelog.previous_entry.date == yesterday
  add_entry(*parse_task(@task))

  save_file
end