Class: PredictabilityEngine::Models::WorkItem
- Inherits:
-
Object
- Object
- PredictabilityEngine::Models::WorkItem
- Defined in:
- lib/predictability_engine/models/work_item.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #age(date = PredictabilityEngine.today) ⇒ Object
- #completed? ⇒ Boolean
- #cycle_time ⇒ Object
- #in_progress?(date) ⇒ Boolean
-
#initialize(item_id:, title: nil, type: nil, priority: nil, start_date: nil, end_date: nil, url: nil) ⇒ WorkItem
constructor
rubocop:disable Metrics/ParameterLists.
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_date ⇒ Object
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 |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/predictability_engine/models/work_item.rb', line 6 def id @id end |
#priority ⇒ Object
Returns the value of attribute priority.
6 7 8 |
# File 'lib/predictability_engine/models/work_item.rb', line 6 def priority @priority end |
#start_date ⇒ Object
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 |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/predictability_engine/models/work_item.rb', line 6 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/predictability_engine/models/work_item.rb', line 6 def type @type end |
#url ⇒ Object
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
30 31 32 |
# File 'lib/predictability_engine/models/work_item.rb', line 30 def completed? !@end_date.nil? && !@start_date.nil? end |
#cycle_time ⇒ Object
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
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 |