Parent

Class Index [+]

Quicksearch

TaskJuggler::AttributeBase

This class is the base for all property attribute types. Each property can have multiple attributes of different type. For each type, there must be a special Ruby class. Each of these classes must be derived from this class. The class holds information like a reference to the property that owns the attribute and the type of the attribute.

The class can track wheter the attribute value was provided by the project file, inherited from another property or computed during scheduling.

Attributes that are of an inherited type will be copied from a parent property or the global scope.

Attributes

property[R]
type[R]
provided[R]
inherited[R]
value[R]

Public Class Methods

mode() click to toggle source

Return the current attribute setting mode.

    # File lib/taskjuggler/AttributeBase.rb, line 70
70:     def AttributeBase.mode
71:       @@mode
72:     end
new(property, type) click to toggle source

Create a new AttributeBase object. type specifies the specific type of the object. property is the PropertyTreeNode object this attribute belongs to.

    # File lib/taskjuggler/AttributeBase.rb, line 38
38:     def initialize(property, type)
39:       @type = type
40:       @property = property
41: 
42:       reset
43:     end
setMode(mode) click to toggle source

Change the @@mode. 0 means values are provided, 1 means values are inherited, any other value means calculated.

    # File lib/taskjuggler/AttributeBase.rb, line 76
76:     def AttributeBase.setMode(mode)
77:       @@mode = mode
78:     end

Public Instance Methods

get() click to toggle source

Return the attribute value.

     # File lib/taskjuggler/AttributeBase.rb, line 103
103:     def get
104:       @value
105:     end
id() click to toggle source

Return the ID of the attribute.

    # File lib/taskjuggler/AttributeBase.rb, line 81
81:     def id
82:       type.id
83:     end
inherit(value) click to toggle source

Call this function to inherit value from the parent property. It is very important that the values are deep copied as they may be modified later on.

    # File lib/taskjuggler/AttributeBase.rb, line 64
64:     def inherit(value)
65:       @inherited = true
66:       @value = value.deep_clone
67:     end
name() click to toggle source

Return the name of the attribute.

    # File lib/taskjuggler/AttributeBase.rb, line 86
86:     def name
87:       type.name
88:     end
nil?() click to toggle source

Check whether the value is uninitialized or nil.

     # File lib/taskjuggler/AttributeBase.rb, line 108
108:     def nil?
109:       if @value.is_a?(Array)
110:         @value.empty?
111:       else
112:         @value.nil?
113:       end
114:     end
reset() click to toggle source

Reset the attribute value to the default value.

    # File lib/taskjuggler/AttributeBase.rb, line 46
46:     def reset
47:       @inherited = false
48:       # Flag that marks whether the value of this attribute was provided by the
49:       # user (in contrast to being calculated).
50:       @provided = false
51:       # If type is an AttributeDefinition, create the initial value according
52:       # to the specified default for this type. Otherwise type is the initial
53:       # value.
54:       if @type.is_a?(AttributeDefinition)
55:         @value = @type.default.deep_clone
56:       else
57:         @value = @type
58:       end
59:     end
set(value) click to toggle source

Set the value of the attribute. Depending on the mode we are in, the flags are updated accordingly.

     # File lib/taskjuggler/AttributeBase.rb, line 92
 92:     def set(value)
 93:       @value = value
 94:       case @@mode
 95:         when 0
 96:           @provided = true
 97:         when 1
 98:           @inherited = true
 99:       end
100:     end
to_num() click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 121
121:     def to_num
122:       if @value.is_a?(Fixnum) || @value.is_a?(Bignum) || @value.is_a?(Float)
123:         @value
124:       else
125:         nil
126:       end
127:     end
to_rti(query) click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 140
140:     def to_rti(query)
141:       @value.is_a?(RichTextIntermediate) ? !value : nil
142:     end
to_s(query = nil) click to toggle source

Return the value as String.

     # File lib/taskjuggler/AttributeBase.rb, line 117
117:     def to_s(query = nil)
118:       @value.to_s
119:     end
to_sort() click to toggle source
     # File lib/taskjuggler/AttributeBase.rb, line 129
129:     def to_sort
130:       if @value.is_a?(Fixnum) || @value.is_a?(Bignum) ||
131:          @value.is_a?(Float)
132:         @value
133:       elsif @value.respond_to?('to_s')
134:         @value.to_s
135:       else
136:         nil
137:       end
138:     end
to_tjp() click to toggle source

Return the value in TJP file syntax.

     # File lib/taskjuggler/AttributeBase.rb, line 145
145:     def to_tjp
146:       @type.id + " " + @value.to_s
147:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.