Class: MPXJ::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/mpxj/project.rb

Overview

Represents a project plan

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ Project

Returns a new instance of Project.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mpxj/project.rb', line 11

def initialize(file_name)
  @resources_by_unique_id = {}
  @tasks_by_unique_id = {}

  @resources_by_id = {}
  @tasks_by_id = {}

  @all_resources = []
  @all_tasks = []
  @all_assignments = []
  @child_tasks = []

  file = File.read(file_name)
  json_data = JSON.parse(file)
  process_properties(json_data)
  process_resources(json_data)
  process_tasks(json_data)
  process_assignments(json_data)
end

Instance Attribute Details

#all_assignmentsObject (readonly)

Returns the value of attribute all_assignments.



10
11
12
# File 'lib/mpxj/project.rb', line 10

def all_assignments
  @all_assignments
end

#all_resourcesObject (readonly)

Returns the value of attribute all_resources.



7
8
9
# File 'lib/mpxj/project.rb', line 7

def all_resources
  @all_resources
end

#all_tasksObject (readonly)

Returns the value of attribute all_tasks.



8
9
10
# File 'lib/mpxj/project.rb', line 8

def all_tasks
  @all_tasks
end

#child_tasksObject (readonly)

Returns the value of attribute child_tasks.



9
10
11
# File 'lib/mpxj/project.rb', line 9

def child_tasks
  @child_tasks
end

#propertiesObject (readonly)

Returns the value of attribute properties.



6
7
8
# File 'lib/mpxj/project.rb', line 6

def properties
  @properties
end

Instance Method Details

#get_resource_by_id(id) ⇒ Resource?

Retrieves the resource with the matching id attribute

Parameters:

  • id (Integer)

    resource ID

Returns:

  • (Resource)

    if the requested resource is found

  • (nil)

    if the requested resource is not found



54
55
56
# File 'lib/mpxj/project.rb', line 54

def get_resource_by_id(id)
  @resources_by_id[id]
end

#get_resource_by_unique_id(unique_id) ⇒ Resource?

Retrieves the resource with the matching unique_id attribute

Parameters:

  • unique_id (Integer)

    resource unique ID

Returns:

  • (Resource)

    if the requested resource is found

  • (nil)

    if the requested resource is not found



36
37
38
# File 'lib/mpxj/project.rb', line 36

def get_resource_by_unique_id(unique_id)
  @resources_by_unique_id[unique_id]
end

#get_task_by_id(id) ⇒ Task?

Retrieves the task with the matching id attribute

Parameters:

  • id (Integer)

    task ID

Returns:

  • (Task)

    if the requested task is found

  • (nil)

    if the requested task is not found



63
64
65
# File 'lib/mpxj/project.rb', line 63

def get_task_by_id(id)
  @tasks_by_unique_id[id]
end

#get_task_by_unique_id(unique_id) ⇒ Task?

Retrieves the task with the matching unique_id attribute

Parameters:

  • unique_id (Integer)

    task unique ID

Returns:

  • (Task)

    if the requested task is found

  • (nil)

    if the requested task is not found



45
46
47
# File 'lib/mpxj/project.rb', line 45

def get_task_by_unique_id(unique_id)
  @tasks_by_unique_id[unique_id]
end