Class: MPXJ::Project
- Inherits:
-
Object
- Object
- MPXJ::Project
- Defined in:
- lib/mpxj/project.rb
Overview
Represents a project plan
Instance Attribute Summary collapse
-
#all_assignments ⇒ Object
readonly
Returns the value of attribute all_assignments.
-
#all_calendars ⇒ Object
readonly
Returns the value of attribute all_calendars.
-
#all_resources ⇒ Object
readonly
Returns the value of attribute all_resources.
-
#all_tasks ⇒ Object
readonly
Returns the value of attribute all_tasks.
-
#child_tasks ⇒ Object
readonly
Returns the value of attribute child_tasks.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
-
#get_alias_by_field(field_type_class, field_type) ⇒ String?
For a particular entity type (task, resource, and so on), retrieve the alias used by the supplied field.
-
#get_calendar_by_unique_id(unique_id) ⇒ Calendar?
Retrieves the calendar with the matching unique_id attribute.
-
#get_field_by_alias(field_type_class, field_alias) ⇒ String?
For a particular entity type (task, resource, and so on), retrieve the field which has the supplied alias.
-
#get_resource_by_id(id) ⇒ Resource?
Retrieves the resource with the matching id attribute.
-
#get_resource_by_unique_id(unique_id) ⇒ Resource?
Retrieves the resource with the matching unique_id attribute.
-
#get_task_by_id(id) ⇒ Task?
Retrieves the task with the matching id attribute.
-
#get_task_by_unique_id(unique_id) ⇒ Task?
Retrieves the task with the matching unique_id attribute.
-
#initialize(file_name, zone) ⇒ Project
constructor
A new instance of Project.
Constructor Details
#initialize(file_name, zone) ⇒ Project
Returns a new instance of Project.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mpxj/project.rb', line 14 def initialize(file_name, zone) @calendars_by_unique_id = {} @resources_by_unique_id = {} @tasks_by_unique_id = {} @resources_by_id = {} @tasks_by_id = {} @all_calendars = [] @all_resources = [] @all_tasks = [] @all_assignments = [] @child_tasks = [] @zone = zone @field_by_alias = {} @alias_by_field = {} file = File.read(file_name) json_data = JSON.parse(file) process_calendars(json_data) process_custom_fields(json_data) process_properties(json_data) process_resources(json_data) process_tasks(json_data) process_assignments(json_data) end |
Instance Attribute Details
#all_assignments ⇒ Object (readonly)
Returns the value of attribute all_assignments.
11 12 13 |
# File 'lib/mpxj/project.rb', line 11 def all_assignments @all_assignments end |
#all_calendars ⇒ Object (readonly)
Returns the value of attribute all_calendars.
7 8 9 |
# File 'lib/mpxj/project.rb', line 7 def all_calendars @all_calendars end |
#all_resources ⇒ Object (readonly)
Returns the value of attribute all_resources.
8 9 10 |
# File 'lib/mpxj/project.rb', line 8 def all_resources @all_resources end |
#all_tasks ⇒ Object (readonly)
Returns the value of attribute all_tasks.
9 10 11 |
# File 'lib/mpxj/project.rb', line 9 def all_tasks @all_tasks end |
#child_tasks ⇒ Object (readonly)
Returns the value of attribute child_tasks.
10 11 12 |
# File 'lib/mpxj/project.rb', line 10 def child_tasks @child_tasks end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
6 7 8 |
# File 'lib/mpxj/project.rb', line 6 def properties @properties end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
12 13 14 |
# File 'lib/mpxj/project.rb', line 12 def zone @zone end |
Instance Method Details
#get_alias_by_field(field_type_class, field_type) ⇒ String?
For a particular entity type (task, resource, and so on), retrieve the alias used by the supplied field. For example this allows the caller to answer the question “does the task field Text1 have an alias?”
111 112 113 114 115 116 |
# File 'lib/mpxj/project.rb', line 111 def get_alias_by_field(field_type_class, field_type) hash = @alias_by_field[field_type_class] if hash hash[field_type] end end |
#get_calendar_by_unique_id(unique_id) ⇒ Calendar?
Retrieves the calendar with the matching unique_id attribute
48 49 50 |
# File 'lib/mpxj/project.rb', line 48 def get_calendar_by_unique_id(unique_id) @calendars_by_unique_id[unique_id] end |
#get_field_by_alias(field_type_class, field_alias) ⇒ String?
For a particular entity type (task, resource, and so on), retrieve the field which has the supplied alias. For example this allows the caller to answer the question “which task field is using the alias ‘Activity ID`”
96 97 98 99 100 101 |
# File 'lib/mpxj/project.rb', line 96 def get_field_by_alias(field_type_class, field_alias) hash = @field_by_alias[field_type_class] if hash hash[field_alias] end end |
#get_resource_by_id(id) ⇒ Resource?
Retrieves the resource with the matching id attribute
75 76 77 |
# File 'lib/mpxj/project.rb', line 75 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
57 58 59 |
# File 'lib/mpxj/project.rb', line 57 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
84 85 86 |
# File 'lib/mpxj/project.rb', line 84 def get_task_by_id(id) @tasks_by_id[id] end |
#get_task_by_unique_id(unique_id) ⇒ Task?
Retrieves the task with the matching unique_id attribute
66 67 68 |
# File 'lib/mpxj/project.rb', line 66 def get_task_by_unique_id(unique_id) @tasks_by_unique_id[unique_id] end |