Class: TaskJuggler::Booking

Inherits:
Object show all
Defined in:
lib/taskjuggler/Booking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, task, intervals) ⇒ Booking

Returns a new instance of Booking.



21
22
23
24
25
26
27
28
# File 'lib/taskjuggler/Booking.rb', line 21

def initialize(resource, task, intervals)
  @resource = resource
  @task = task
  @intervals = intervals
  @sourceFileInfo = nil
  @overtime = 0
  @sloppy = 0
end

Instance Attribute Details

#intervalsObject (readonly)

Returns the value of attribute intervals.



18
19
20
# File 'lib/taskjuggler/Booking.rb', line 18

def intervals
  @intervals
end

#overtimeObject

Returns the value of attribute overtime.



19
20
21
# File 'lib/taskjuggler/Booking.rb', line 19

def overtime
  @overtime
end

#resourceObject (readonly)

Returns the value of attribute resource.



18
19
20
# File 'lib/taskjuggler/Booking.rb', line 18

def resource
  @resource
end

#sloppyObject

Returns the value of attribute sloppy.



19
20
21
# File 'lib/taskjuggler/Booking.rb', line 19

def sloppy
  @sloppy
end

#sourceFileInfoObject

Returns the value of attribute sourceFileInfo.



19
20
21
# File 'lib/taskjuggler/Booking.rb', line 19

def sourceFileInfo
  @sourceFileInfo
end

#taskObject (readonly)

Returns the value of attribute task.



18
19
20
# File 'lib/taskjuggler/Booking.rb', line 18

def task
  @task
end

Instance Method Details

#to_sObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/taskjuggler/Booking.rb', line 30

def to_s
  out = "#{@resource.fullId} "
  first = true
  @intervals.each do |iv|
    if first
      first = false
    else
      out += ", "
    end
    out += "#{iv.start} + #{(iv.end - iv.start) / 3600}h"
  end
end

#to_tjp(taskMode) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/taskjuggler/Booking.rb', line 43

def to_tjp(taskMode)
  out = taskMode ? "#{@task.fullId} " : "#{@resource.fullId} "
  first = true
  @intervals.each do |iv|
    if first
      first = false
    else
      out += ",\n"
    end
    out += "#{iv.start} + #{(iv.end - iv.start) / 3600}h"
  end
  out += ' { overtime 2 }'
end