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

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/AttributeBase.rb, line 34
34:     def initialize(property, type)
35:       @type = type
36:       @property = property
37:       # Flag that marks whether the value of this attribute was inherited from
38:       # the parent PropertyTreeNode.
39:       @inherited = false
40:       # Flag that marks whether the value of this attribute was provided by the
41:       # user (in contrast to being calculated).
42:       @provided = false
43:       # If type is an AttributeDefinition, create the initial value according
44:       # to the specified default for this type. Otherwise type is the initial
45:       # value.
46:       if @type.is_a?(AttributeDefinition)
47:         @value = @type.default.deep_clone
48:       else
49:         @value = @type
50:       end
51:       # The mode is flag that controls how value assignments affect the flags.
52:       @@mode = 0
53:     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/AttributeBase.rb, line 65
65:     def AttributeBase.setMode(mode)
66:       @@mode = mode
67:     end

Public Instance Methods

get() click to toggle source

Return the attribute value.

    # File lib/AttributeBase.rb, line 92
92:     def get
93:       @value
94:     end
id() click to toggle source

Return the ID of the attribute.

    # File lib/AttributeBase.rb, line 70
70:     def id
71:       type.id
72:     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/AttributeBase.rb, line 58
58:     def inherit(value)
59:       @inherited = true
60:       @value = value.deep_clone
61:     end
name() click to toggle source

Return the name of the attribute.

    # File lib/AttributeBase.rb, line 75
75:     def name
76:       type.name
77:     end
nil?() click to toggle source

Check whether the value is uninitialized or nil.

     # File lib/AttributeBase.rb, line 97
 97:     def nil?
 98:       if @value.is_a?(Array)
 99:         @value.empty?
100:       else
101:         @value.nil?
102:       end
103:     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/AttributeBase.rb, line 81
81:     def set(value)
82:       @value = value
83:       case @@mode
84:         when 0
85:           @provided = true
86:         when 1
87:           @inherited = true
88:       end
89:     end
to_num() click to toggle source
     # File lib/AttributeBase.rb, line 110
110:     def to_num
111:       if @value.is_a?(Fixnum) || @value.is_a?(Bignum) || @value.is_a?(Float)
112:         @value
113:       else
114:         nil
115:       end
116:     end
to_rti(query) click to toggle source
     # File lib/AttributeBase.rb, line 129
129:     def to_rti(query)
130:       @value.is_a?(RichTextIntermediate) ? !value : nil
131:     end
to_s(query = nil) click to toggle source

Return the value as String.

     # File lib/AttributeBase.rb, line 106
106:     def to_s(query = nil)
107:       @value.to_s
108:     end
to_sort() click to toggle source
     # File lib/AttributeBase.rb, line 118
118:     def to_sort
119:       if @value.is_a?(Fixnum) || @value.is_a?(Bignum) ||
120:          @value.is_a?(Float)
121:         @value
122:       elsif @value.respond_to?('to_s')
123:         @value.to_s
124:       else
125:         nil
126:       end
127:     end
to_tjp() click to toggle source

Return the value in TJP file syntax.

     # File lib/AttributeBase.rb, line 134
134:     def to_tjp
135:       @type.id + " " + @value.to_s
136:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.