Class: Taskchampion::Task

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

Overview

Task convenience methods

Instance Method Summary collapse

Instance Method Details

#update_annotation(annotation, new_description, operations) ⇒ void

This method returns an undefined value.

Update an existing annotation’s description while preserving its timestamp

This is a convenience method that removes the old annotation and adds a new one with the same timestamp, effectively updating the description while maintaining the original creation time for chronological history.

Examples:

Update an annotation

annotation = task.annotations.first
task.update_annotation(annotation, "Updated note", operations)
replica.commit_operations(operations)

Parameters:

  • annotation (Taskchampion::Annotation)

    The annotation to update

  • new_description (String)

    The new description text

  • operations (Taskchampion::Operations)

    Operations collection

Raises:

  • (Taskchampion::ValidationError)

    if new_description is empty or whitespace-only



80
81
82
83
84
85
86
# File 'lib/taskchampion.rb', line 80

def update_annotation(annotation, new_description, operations)
  # Remove the old annotation
  remove_annotation(annotation, operations)

  # Add new annotation with the preserved timestamp
  add_annotation_with_timestamp(annotation.entry, new_description, operations)
end