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(action_record, prefix) ⇒ Parser

Returns a new instance of Parser.



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

def initialize(action_record, prefix)
  @action_record = action_record
  @prefix = prefix
end

Instance Method Details

#parseObject

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
  record = ActivityRecord.new()

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

  record
end