Module: Pomodoro::Formats::Scheduled

Defined in:
lib/pomodoro/formats/scheduled.rb,
lib/pomodoro/formats/scheduled/task.rb,
lib/pomodoro/formats/scheduled/task_list.rb,
lib/pomodoro/formats/scheduled/task_group.rb,
lib/pomodoro/formats/scheduled/parser/parser.rb,
lib/pomodoro/formats/scheduled/parser/transformer.rb

Overview

Defined Under Namespace

Classes: Parser, Task, TaskGroup, TaskList, Transformer

Class Method Summary collapse

Class Method Details

.parse(string_or_io) ⇒ TaskList?

The entry point method for parsing this format.

Examples:

require 'pomodoro/formats/scheduled'

task_list = Pomodoro::Formats::Scheduled.parse <<-EOF.gsub(/^\s*/, '')
  Tomorrow
  - Buy milk. #errands
  - [9:20] Call with Mike.

  Prague
  - Pick up my shoes. #errands
EOF

Parameters:

  • string (String)

    string in the scheduled task list format

Returns:

Since:

  • 0.2


27
28
29
30
31
32
# File 'lib/pomodoro/formats/scheduled.rb', line 27

def self.parse(string_or_io)
  string = string_or_io.respond_to?(:read) ? string_or_io.read : string_or_io
  tree = Parser.new.parse_with_debug(string)
  nodes = Transformer.new.apply(tree)
  TaskList.new(nodes.empty? ? Array.new : nodes)
end