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-5.8.0 lib/mpxj/task.rb
mpxj-5.7.1 lib/mpxj/task.rb
mpxj-5.7.0 lib/mpxj/task.rb
mpxj-5.6.5 lib/mpxj/task.rb
mpxj-5.6.4 lib/mpxj/task.rb
mpxj-5.6.3 lib/mpxj/task.rb
mpxj-5.6.2 lib/mpxj/task.rb
mpxj-5.6.1 lib/mpxj/task.rb
mpxj-5.6.0 lib/mpxj/task.rb
mpxj-5.5.9 lib/mpxj/task.rb
mpxj-5.5.8 lib/mpxj/task.rb
mpxj-5.5.7 lib/mpxj/task.rb
mpxj-5.5.6 lib/mpxj/task.rb
mpxj-5.5.5 lib/mpxj/task.rb
mpxj-5.5.4 lib/mpxj/task.rb
mpxj-5.5.3 lib/mpxj/task.rb
mpxj-5.5.2 lib/mpxj/task.rb
mpxj-5.5.1 lib/mpxj/task.rb
mpxj-5.5.0 lib/mpxj/task.rb
mpxj-5.4.0 lib/mpxj/task.rb