Class: TimeTrello::TrelloDriver

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

Overview

Public: Driver responsible to convert data gathered from Trello to an internal representation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(board_id, prefix) ⇒ TrelloDriver

Returns a new instance of TrelloDriver.



23
24
25
26
27
28
# File 'lib/time_trello/trello_driver.rb', line 23

def initialize(board_id, prefix)
  @board_id = board_id
  @prefix = prefix
  @activities = []
  @board = nil
end

Instance Attribute Details

#board_idObject

Returns the value of attribute board_id.



20
21
22
# File 'lib/time_trello/trello_driver.rb', line 20

def board_id
  @board_id
end

#prefixObject

Returns the value of attribute prefix.



21
22
23
# File 'lib/time_trello/trello_driver.rb', line 21

def prefix
  @prefix
end

Instance Method Details

#activitiesObject

Public: Getter. Gets all activities for a given board.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/time_trello/trello_driver.rb', line 38

def activities
  return @activities if @activities != nil && @activities.length > 0
  
  @activities = []
  self.board.cards.each do |card|
    card.actions.each do |action|
      member = Trello::Member.find(action.member_creator_id)
      action_record = {action: action, member: member}
      activity = (Parser.new(action_record, @prefix)).parse
      @activities.push(activity) unless activity == nil
    end
  end
  
  @activities
end

#boardObject

Public: Getter. Gets a board, based on a board id.



31
32
33
34
35
# File 'lib/time_trello/trello_driver.rb', line 31

def board
  @board = Trello::Board.find(@board_id) if @board == nil

  @board
end