Class: Bosh::Cli::TaskTracking::Task

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage, name, progress, callbacks) ⇒ Task

Returns a new instance of Task.



89
90
91
92
93
94
95
# File 'lib/cli/task_tracking/stage_collection.rb', line 89

def initialize(stage, name, progress, callbacks)
  @stage = stage
  @name = name
  @progress = progress
  @callbacks = callbacks
  @total_duration = TotalDuration.new
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



84
85
86
# File 'lib/cli/task_tracking/stage_collection.rb', line 84

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name.



84
85
86
# File 'lib/cli/task_tracking/stage_collection.rb', line 84

def name
  @name
end

#progressObject (readonly)

Returns the value of attribute progress.



84
85
86
# File 'lib/cli/task_tracking/stage_collection.rb', line 84

def progress
  @progress
end

#stageObject (readonly)

Returns the value of attribute stage.



84
85
86
# File 'lib/cli/task_tracking/stage_collection.rb', line 84

def stage
  @stage
end

#stateObject (readonly)

Returns the value of attribute state.



84
85
86
# File 'lib/cli/task_tracking/stage_collection.rb', line 84

def state
  @state
end

Instance Method Details

#update_with_event(event) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/cli/task_tracking/stage_collection.rb', line 97

def update_with_event(event)
  @state    = event['state']
  @progress = event['progress']
  @error    = (event['data'] || {})['error']

  @total_duration.started_at  = event['time'] if @state == 'started'
  @total_duration.finished_at = event['time'] if @state == 'finished' || @state == 'failed'

  call_state_callback
end