Sha256: faf020f96a189f398bd30657e7cd6678268df979457d17c905d046c0c21896ab

Contents?: true

Size: 1.34 KB

Versions: 126

Compression:

Stored size: 1.34 KB

Contents

module MPXJ
  # Represents a task in a project plan
  class Task < Container
    attr_reader :assignments
    attr_reader :predecessors
    attr_reader :successors
    attr_reader :child_tasks

    def initialize(parent_project, attribute_types, attribute_values)
      super(parent_project, attribute_types, attribute_values)
      @assignments = []
      @child_tasks = []
      process_relations
      process_hierarchy
    end

    # Retrieve the parent task of this task
    #
    # @return [Task] if this task is the child of another task
    # @return [nil] if this is the root task
    def parent_task
      parent_project.get_task_by_unique_id(parent_task_unique_id)
    end

    private

    RELATION_ATTRIBUTE_TYPES = {"task_unique_id" => 17, "lag" => 6, "type" => 10}

    def process_relations
      @predecessors = process_relation_list(attribute_values["predecessors"])
      @successors = process_relation_list(attribute_values["successors"])
    end

    def process_relation_list(list)
      result = []
      if list
        list.each do |attribute_values|
          result << Relation.new(self, RELATION_ATTRIBUTE_TYPES, attribute_values)
        end
      end
      result
    end

    def process_hierarchy
      if parent_task
        parent_task.child_tasks << self
      else
        parent_project.child_tasks << self
      end
    end
  end
end

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
mpxj-9.4.0 lib/mpxj/task.rb
mpxj-9.3.1 lib/mpxj/task.rb
mpxj-9.3.0 lib/mpxj/task.rb
mpxj-9.2.6 lib/mpxj/task.rb
mpxj-9.2.5 lib/mpxj/task.rb
mpxj-9.2.4 lib/mpxj/task.rb
mpxj-9.2.3 lib/mpxj/task.rb
mpxj-9.2.2 lib/mpxj/task.rb
mpxj-9.2.1 lib/mpxj/task.rb
mpxj-9.1.0 lib/mpxj/task.rb
mpxj-9.0.0 lib/mpxj/task.rb
mpxj-8.5.1 lib/mpxj/task.rb
mpxj-8.5.0 lib/mpxj/task.rb
mpxj-8.4.0 lib/mpxj/task.rb
mpxj-8.3.5 lib/mpxj/task.rb
mpxj-8.3.4 lib/mpxj/task.rb
mpxj-8.3.3 lib/mpxj/task.rb
mpxj-8.3.2 lib/mpxj/task.rb
mpxj-8.3.1 lib/mpxj/task.rb
mpxj-8.3.0 lib/mpxj/task.rb