class DTK::Client::TaskStatus::StreamMode::Element
Copyright (C) 2010-2016 dtk contributors
This file is part of the dtk project.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (C) 2010-2016 dtk contributors
This file is part of the dtk project.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Public Class Methods
# File lib/task_status/stream_mode/element.rb, line 39 def self.get_and_render_stages(task_status_handle, opts = {}) Stage.get_and_render_stages(task_status_handle, opts) end
# File lib/task_status/stream_mode/element.rb, line 35 def self.get_and_render_task_start(task_status_handle, opts = {}) render_elements(TaskStart.get(task_status_handle, opts)) end
# File lib/task_status/stream_mode/element.rb, line 29 def initialize(response_element, opts = {}) @response_element = response_element @formatter = Format.new(response_element['type']) @ignore_stage_level_info = opts[:ignore_stage_level_info] end
Private Class Methods
# File lib/task_status/stream_mode/element.rb, line 64 def self.create(response_element, opts) type = response_element['type'] case type && type.to_sym when :task_start then TaskStart.new(response_element, opts) when :task_end then TaskEnd.new(response_element, opts) when :stage then Stage.new(response_element, opts) when :stage_start then Stage.new(response_element, {:just_render => :start}.merge(opts)) when :stage_end then Stage.new(response_element, {:just_render => :end}.merge(opts)) when :no_results then NoResults.new(response_element, opts) else raise DtkError::Client.new("Unexpected element type '#{type}'") end end
opts can have
:ignore_stage_level_info - Boolean
# File lib/task_status/stream_mode/element.rb, line 57 def self.create_elements(response, opts = {}) response_elements = response.data unless response_elements.kind_of?(Array) raise DtkError::Client.new("Unexpected that response.data no at array") end response_elements.map { |el| create(el, opts) } end
opts will have
:start_index :end_index
opts can have
:ignore_stage_level_info - Boolean
# File lib/task_status/stream_mode/element.rb, line 50 def self.get_task_status_elements(task_status_handle, element_type, opts = {}) response = task_status_handle.post_call(opts.merge(:form => :stream_form)) create_elements(response, opts) end
# File lib/task_status/stream_mode/element.rb, line 81 def self.no_results_yet?(elements) elements.find{|el|el.kind_of?(NoResults)} end
# File lib/task_status/stream_mode/element.rb, line 85 def self.render_elements(elements) elements.each{ |el| el.render } end
# File lib/task_status/stream_mode/element.rb, line 77 def self.task_end?(elements) elements.empty? or elements.last.kind_of?(TaskEnd) end
Private Instance Methods
# File lib/task_status/stream_mode/element.rb, line 97 def field?(field) @response_element[field.to_s] end
# File lib/task_status/stream_mode/element.rb, line 93 def render_stage_results(subtasks) HierarchicalTask.render_results(self, subtasks) end
# File lib/task_status/stream_mode/element.rb, line 89 def render_stage_steps(subtasks) HierarchicalTask.render_steps(self, subtasks) end