Class: Diagrams::Elements::Task

Inherits:
Dry::Struct
  • Object
show all
Includes:
Types
Defined in:
lib/diagrams/elements/task.rb

Overview

Represents a task in a Gantt Diagram.

Constant Summary collapse

STATUS =

Status symbols allowed by Mermaid Gantt

Types::Strict::Symbol.enum(:done, :active, :crit)

Instance Method Summary collapse

Instance Method Details

#to_hHash{Symbol => String | Symbol | nil}

Returns a hash representation suitable for serialization.

Returns:

  • (Hash{Symbol => String | Symbol | nil})


23
24
25
26
27
28
29
30
31
32
# File 'lib/diagrams/elements/task.rb', line 23

def to_h
  hash = {
    id: id,
    label: label,
    start: start,
    duration: duration
  }
  hash[:status] = status if status # Include status only if set
  hash
end