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.
Return the current attribute setting mode.
# File lib/taskjuggler/AttributeBase.rb, line 70 70: def AttributeBase.mode 71: @@mode 72: end
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
Return the attribute value.
# File lib/taskjuggler/AttributeBase.rb, line 103 103: def get 104: @value 105: end
Return the ID of the attribute.
# File lib/taskjuggler/AttributeBase.rb, line 81 81: def id 82: type.id 83: end
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
Return the name of the attribute.
# File lib/taskjuggler/AttributeBase.rb, line 86 86: def name 87: type.name 88: end
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 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 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
# 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
# File lib/taskjuggler/AttributeBase.rb, line 140 140: def to_rti(query) 141: @value.is_a?(RichTextIntermediate) ? !value : nil 142: end
Return the value as String.
# File lib/taskjuggler/AttributeBase.rb, line 117 117: def to_s(query = nil) 118: @value.to_s 119: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.