Class: OmnifocusParser::Builder

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

Constant Summary collapse

MAPPING =
{
  "Project" => Project,
  "Action" => Action
}

Class Method Summary collapse

Class Method Details

.from_row(row) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/omnifocus_parser/builder.rb', line 8

def self.from_row(row)
  task_id = row.fetch("Task ID")
  type = row.fetch("Type")
  name = row.fetch("Name")
  status = row.fetch("Status")
  project = row.fetch("Project")
  context = row.fetch("Context")
  due_date = row.fetch("Due Date")&.then { DateTime.parse(_1) }
  completion_date = row.fetch("Completion Date")&.then { Date.parse(_1) }
  duration = row.fetch("Duration")
  start_date = row.fetch("Start Date")&.then { DateTime.parse(_1) }
  flagged = row.fetch("Flagged") == "1"
  notes = row.fetch("Notes")
  tags = row.fetch("Tags")&.split(",")

  MAPPING.fetch(type).new(
    task_id: task_id,
    name: name,
    status: status,
    project: project,
    context: context,
    due_date: due_date,
    completion_date: completion_date,
    duration: duration,
    start_date: start_date,
    flagged: flagged,
    notes: notes,
    tags: tags
  )
end