Class: PredictabilityEngine::Models::WorkItem

Inherits:
Object
  • Object
show all
Defined in:
lib/predictability_engine/models/work_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_id:, title: nil, type: nil, priority: nil, start_date: nil, end_date: nil, url: nil) ⇒ WorkItem

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
# File 'lib/predictability_engine/models/work_item.rb', line 8

def initialize(item_id:, title: nil, type: nil, priority: nil, start_date: nil, end_date: nil, url: nil) # rubocop:disable Metrics/ParameterLists
  @id = item_id
  @title = title
  @type = type
  @priority = priority
  @start_date = start_date ? Date.parse(start_date.to_s) : nil
  @end_date = end_date ? Date.parse(end_date.to_s) : nil
  @url = url
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def end_date
  @end_date
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def id
  @id
end

#priorityObject

Returns the value of attribute priority.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def priority
  @priority
end

#start_dateObject

Returns the value of attribute start_date.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def start_date
  @start_date
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def title
  @title
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def type
  @type
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/predictability_engine/models/work_item.rb', line 6

def url
  @url
end

Instance Method Details

#age(date = PredictabilityEngine.today) ⇒ Object



24
25
26
27
28
# File 'lib/predictability_engine/models/work_item.rb', line 24

def age(date = PredictabilityEngine.today)
  return nil unless in_progress?(date)

  (date - @start_date).to_i + 1
end

#completed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/predictability_engine/models/work_item.rb', line 30

def completed?
  !@end_date.nil? && !@start_date.nil?
end

#cycle_timeObject



18
19
20
21
22
# File 'lib/predictability_engine/models/work_item.rb', line 18

def cycle_time
  return nil unless completed?

  (@end_date - @start_date).to_i + 1 # Include both start and end days
end

#in_progress?(date) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/predictability_engine/models/work_item.rb', line 34

def in_progress?(date)
  return false unless @start_date
  return false if date < @start_date
  return true if @end_date.nil? || date < @end_date

  false
end