Class: Logbook::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/logbook/task.rb

Constant Summary collapse

DONE =
"Done"
PAUSE =
"Pause"
REOPEN =
"Reopen"
RESUME =
"Resume"
START =
"Start"
TASK_ID_PROPERTY =
"ID"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Task

Returns a new instance of Task.



12
13
14
15
16
17
# File 'lib/logbook/task.rb', line 12

def initialize(id)
  @entries = []
  @id = id
  @properties = {}
  @time_logged = Duration.new(0)
end

Instance Attribute Details

#entriesObject

Returns the value of attribute entries.



3
4
5
# File 'lib/logbook/task.rb', line 3

def entries
  @entries
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/logbook/task.rb', line 3

def id
  @id
end

#propertiesObject

Returns the value of attribute properties.



3
4
5
# File 'lib/logbook/task.rb', line 3

def properties
  @properties
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/logbook/task.rb', line 3

def status
  @status
end

#time_loggedObject

Returns the value of attribute time_logged.



3
4
5
# File 'lib/logbook/task.rb', line 3

def time_logged
  @time_logged
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/logbook/task.rb', line 3

def title
  @title
end

Instance Method Details

#add_entry(entry) ⇒ Object



19
20
21
22
23
# File 'lib/logbook/task.rb', line 19

def add_entry(entry)
  self.properties.merge!(entry.properties)
  self.status = entry.status
  self.title = entry.title
end

#log_work(entry, duration) ⇒ Object



25
26
27
28
29
# File 'lib/logbook/task.rb', line 25

def log_work(entry, duration)
  add_entry(entry)

  self.time_logged += duration
end