class TimeTrello::Report

Public: This class represents a report manager on the time trello structure. It coordinates efforts with the persistence manager in order to collect data from a given trello board.

Attributes

board_id[RW]

Public: board identification for reporting

end_date[RW]

Public: Report end date

prefix[RW]

Public: Prefix for proper filtering

start_date[RW]

Public: Report start date

Public Class Methods

new(start_date, end_date, board_id, prefix) click to toggle source

Public: Initializes this class providing initial filter information

start_date - Used to limit the result set. It is the start of time records end_date - Used to limit the result set. It is the end of time records board_id - Identification of the given board. Used to grab information from an specific board.

# File lib/time_trello/report.rb, line 40
def initialize(start_date, end_date, board_id, prefix)
  @start_date = start_date
  @end_date = end_date
  @board_id = board_id
  @prefix = prefix
end

Public Instance Methods

board_id=(board_id) click to toggle source

Public: Setter. Overrides the board_id setter in order to re-initialize the driver properly with new settings.

# File lib/time_trello/report.rb, line 68
def board_id=(board_id)
  if board_id != @board_id
    @board_id = board_id
    # Forces the driver reload with the new settings
    @driver = nil
  end
end
find_all(&filter) click to toggle source

Public: Generates the report based on a filter, if provided. The filter is a block that will filter the result set accordingly. The result set is

always an array containing instances of ActivityRecord. See

ActivityRecord

filter - Block used to filter the result set even further. It must follow the same format for the block passed as parameter to Array.find_all method. Each element on the array is, in fact, an instance of TimeTrello::ActivityRecord

# File lib/time_trello/report.rb, line 56
def find_all &filter
  result_set = self.driver.activities.find_all { |activity| activity.start_date >= @start_date && activity.start_date <= @end_date }

  if filter
    return result_set.find_all &filter  
  end

  result_set
end

Protected Instance Methods

driver() click to toggle source

Private: Getter for trello driver.

# File lib/time_trello/report.rb, line 18
def driver
  @driver = TrelloDriver.new(@board_id, @prefix) if @driver == nil

  @driver
end