Class: TaskJuggler::Leave

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

Overview

This class describes a leave.

Constant Summary collapse

Types =

This Hash defines the supported leave types. It maps the symbol to its index. The index sequence is important when multiple leaves are defined for the same time slot. A subsequent definition with a type with a larger index will override the old leave type.

{
  :project => 1,
  :annual => 2,
  :special => 3,
  :sick => 4,
  :unpaid => 5,
  :holiday => 6,
  :unemployed => 7
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, interval, reason = nil) ⇒ Leave

Create a new Leave object. interval should be an Interval describing the leave period. type must be one of the supported leave types (:holiday, :annual, :special, :unpaid, :sick and :project ). The reason is an optional String that describes the leave reason.



39
40
41
42
43
44
45
46
# File 'lib/taskjuggler/LeaveList.rb', line 39

def initialize(type, interval, reason = nil)
  unless Types[type]
    raise ArgumentError, "Unsupported leave type #{type}"
  end
  @type = type
  @interval = interval
  @reason = reason
end

Instance Attribute Details

#intervalObject (readonly)

Returns the value of attribute interval.



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

def interval
  @interval
end

#reasonObject (readonly)

Returns the value of attribute reason.



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

def reason
  @reason
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#to_sObject



52
53
54
# File 'lib/taskjuggler/LeaveList.rb', line 52

def to_s
  "#{@type} #{@reason ? "\"#{@reason}\"" : ""} #{@interval}"
end

#typeIdxObject



48
49
50
# File 'lib/taskjuggler/LeaveList.rb', line 48

def typeIdx
  Types[@type]
end