Module: Asposetasksjava::CalculateTaskDuration

Defined in:
lib/asposetasksjava/Tasks/calculatetaskduration.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/asposetasksjava/Tasks/calculatetaskduration.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    # Instantiate project object
    project = Rjb::import('com.aspose.tasks.Project').new(data_dir + 'test_tasks.mpp')

    tsk = Rjb::import('com.aspose.tasks.Tsk')
    time_unit_type = Rjb::import('com.aspose.tasks.TimeUnitType')

    # Get a task to calculate its duration in different formats
		task = project.getRootTask().getChildren().getById(1)

		# Get the duration in Minutes
		puts task.get(tsk.DURATION).convert(time_unit_type.Minute).toDouble()

		# Get the duration in Days
		puts task.get(tsk.DURATION).convert(time_unit_type.Day).toDouble()
		
		# Get the duration in Hours
		puts task.get(tsk.DURATION).convert(time_unit_type.Hour).toDouble()
		
		# Get the duration in Weeks
		puts task.get(tsk.DURATION).convert(time_unit_type.Week).toDouble()
		
		# Get the duration in Months
		puts task.get(tsk.DURATION).convert(time_unit_type.Month).toDouble()
end