Class: Logbook::TaskEntry

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

Constant Summary collapse

DATE_PROPERTY_NAME =
"Date"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#line_numberObject

Returns the value of attribute line_number

Returns:

  • (Object)

    the current value of line_number



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def line_number
  @line_number
end

#noteObject

Returns the value of attribute note

Returns:

  • (Object)

    the current value of note



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def note
  @note
end

#propertiesObject

Returns the value of attribute properties

Returns:

  • (Object)

    the current value of properties



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def properties
  @properties
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def status
  @status
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of time



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def time
  @time
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



4
5
6
# File 'lib/logbook/task_entry.rb', line 4

def title
  @title
end

Instance Method Details

#belongs_to_task?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/logbook/task_entry.rb', line 7

def belongs_to_task?
  self.properties.has_key?(Task::TASK_ID_PROPERTY) &&
    self.properties[Task::TASK_ID_PROPERTY].has_value?
end

#merge_page_properties(properties) ⇒ Object



12
13
14
# File 'lib/logbook/task_entry.rb', line 12

def merge_page_properties(properties)
  self.properties = properties.merge(self.properties)
end

#recorded_atObject



16
17
18
19
20
21
22
# File 'lib/logbook/task_entry.rb', line 16

def recorded_at
  date = self.properties[DATE_PROPERTY_NAME].value
  time = self.time

  DateTime.parse(date + " " + time)
rescue ArgumentError
end

#starts_clock?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/logbook/task_entry.rb', line 24

def starts_clock?
  [Task::START, Task::RESUME, Task::REOPEN].include?(self.status)
end

#task_idObject



28
29
30
# File 'lib/logbook/task_entry.rb', line 28

def task_id
  self.properties[Task::TASK_ID_PROPERTY].value
end