Class: Bosh::Cli::TaskTracking::Stage
- Defined in:
- lib/cli/task_tracking/stage_collection.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(name, tags, total, callbacks) ⇒ Stage
constructor
A new instance of Stage.
- #update_with_event(event) ⇒ Object
Constructor Details
#initialize(name, tags, total, callbacks) ⇒ Stage
Returns a new instance of Stage.
24 25 26 27 28 29 30 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 24 def initialize(name, , total, callbacks) @name = name @tags = Array() @total = total @callbacks = callbacks @tasks = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 22 def name @name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
22 23 24 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 22 def @tags end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
22 23 24 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 22 def tasks @tasks end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
22 23 24 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 22 def total @total end |
Instance Method Details
#duration ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 45 def duration total_duration = TotalDuration.new task_start_times = @tasks.map(&:started_at) task_end_times = @tasks.map(&:finished_at) # If any task start time is nil, the start time for the entire stage is unknown. total_duration.started_at = task_start_times.min unless task_start_times.include?(nil) total_duration.finished_at = task_end_times.max unless task_end_times.include?(nil) total_duration.duration end |
#update_with_event(event) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 32 def update_with_event(event) new_task = Task.new(self, event['task'], event['progress'], @callbacks) unless found_task = @tasks.find { |t| t.name == new_task.name } found_task = new_task @tasks << new_task end fire_started_callback(event) found_task.update_with_event(event) fire_finished_callback(event) fire_failed_callback(event) found_task end |