Class: TimeTrello::ActivityRecord

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/time_trello/activity_record.rb

Overview

Public: An activity record identifies completely an activity done in trello. Its main ideia is to be a standard record that can be compared, sorted and collected, used for reporting purposes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ActivityRecord

Public: Initializes this class with proper information about a given task

project - Project name (i.e., the board name) owner - Name of the duration owner start_date - When the task started duration - The task duration



39
40
41
42
43
44
45
46
47
48
# File 'lib/time_trello/activity_record.rb', line 39

def initialize(*args)
  if args.size != 0
    @id                = args[0]
    @duration          = args[1]
    @owner             = args[2]
    @project           = args[3]
    @start_date        = args[4]
    @task_description  = args[5]
  end
end

Instance Attribute Details

#durationObject

Public: Task duration



23
24
25
# File 'lib/time_trello/activity_record.rb', line 23

def duration
  @duration
end

#idObject

Public: This activity id. This is, actually, Trello’s Action Identification.



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

def id
  @id
end

#ownerObject

Public: Task owner



25
26
27
# File 'lib/time_trello/activity_record.rb', line 25

def owner
  @owner
end

#projectObject

Public: Project name (i.e., Trello board)



27
28
29
# File 'lib/time_trello/activity_record.rb', line 27

def project
  @project
end

#start_dateObject

Public: Task start date



29
30
31
# File 'lib/time_trello/activity_record.rb', line 29

def start_date
  @start_date
end

#task_descriptionObject

Public: Task comment



31
32
33
# File 'lib/time_trello/activity_record.rb', line 31

def task_description
  @task_description
end

Instance Method Details

#<=>(other) ⇒ Object

Public: Implementation of Comparable mixin. The comparison is done following this attributes hierarchy:

  • project

  • owner

  • start_date

other - The other instance of ActivityRecord to compare with.



57
58
59
60
61
62
63
64
65
66
# File 'lib/time_trello/activity_record.rb', line 57

def <=>(other)
  if other == nil
    return -1
  end
  result = @project <=> other.project
  result = @owner <=> other.owner if result == 0
  result = @start_date <=> other.start_date if result == 0
  
  result
end