Class: Bosh::Cli::TaskTracking::Task
- Extended by:
- Forwardable
- Defined in:
- lib/cli/task_tracking/stage_collection.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #done? ⇒ Boolean
- #failed? ⇒ Boolean
- #finished? ⇒ Boolean
-
#initialize(stage, name, index, progress, callbacks) ⇒ Task
constructor
A new instance of Task.
- #update_with_event(event) ⇒ Object
Constructor Details
#initialize(stage, name, index, progress, callbacks) ⇒ Task
Returns a new instance of Task.
120 121 122 123 124 125 126 127 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 120 def initialize(stage, name, index, progress, callbacks) @stage = stage @name = name @index = index @progress = progress @callbacks = callbacks @total_duration = TotalDuration.new end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def error @error end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def name @name end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def progress @progress end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def stage @stage end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
115 116 117 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 115 def state @state end |
Instance Method Details
#==(other) ⇒ Object
140 141 142 143 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 140 def ==(other) return false unless other.is_a?(Task) [stage, index, name] == [other.stage, other.index, other.name] end |
#done? ⇒ Boolean
145 146 147 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 145 def done? %w(failed finished).include?(@state) end |
#failed? ⇒ Boolean
149 150 151 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 149 def failed? @state == 'failed' end |
#finished? ⇒ Boolean
153 154 155 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 153 def finished? @state == 'finished' end |
#update_with_event(event) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cli/task_tracking/stage_collection.rb', line 129 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 |