Class: Bosh::Cli::TaskTracking::StageCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/task_tracking/stage_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callbacks) ⇒ StageCollection

Returns a new instance of StageCollection.



5
6
7
8
# File 'lib/cli/task_tracking/stage_collection.rb', line 5

def initialize(callbacks)
  @stages = []
  @callbacks = callbacks
end

Instance Attribute Details

#stagesObject (readonly)

Returns the value of attribute stages.



3
4
5
# File 'lib/cli/task_tracking/stage_collection.rb', line 3

def stages
  @stages
end

Instance Method Details

#update_with_event(event) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/cli/task_tracking/stage_collection.rb', line 10

def update_with_event(event)
  new_stage = Stage.new(event['stage'], event['tags'], event['total'], @callbacks)
  unless found_stage = @stages.find { |s| s == new_stage }
    found_stage = new_stage
    @stages << new_stage
  end
  found_stage.update_with_event(event)
  found_stage
end