Class: TimeTrello::Parser

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

Overview

Public: Parser for Trello::Action to ActivityRecord conversion. See ruby-trello for Trello::Action class specification.

Instance Method Summary collapse

Constructor Details

#initialize(prefix) ⇒ Parser

Returns a new instance of Parser.



102
103
104
# File 'lib/time_trello/parser.rb', line 102

def initialize(prefix)
  @prefix = prefix
end

Instance Method Details

#parse(action_record) ⇒ Object

Public: Parses the action_record, building an instance of ActivityRecord. This parser is based on a workflow defined by a constant array of blocks. Each block is a step that will be executed in sequence.



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/time_trello/parser.rb', line 109

def parse(action_record)
  parsed_record = ActivityRecord.new()

  for step in self.workflow
    if !step.call(action_record, parsed_record)
      # Workflow was interrupted. Not necessarily an error. Possibly the
      # action_record was not the one we are looking for.
      return nil
    end
  end

  parsed_record
end