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.
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
Return the attribute value.
# File lib/AttributeBase.rb, line 92 92: def get 93: @value 94: end
Return the ID of the attribute.
# File lib/AttributeBase.rb, line 70 70: def id 71: type.id 72: 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/AttributeBase.rb, line 58 58: def inherit(value) 59: @inherited = true 60: @value = value.deep_clone 61: end
Return the name of the attribute.
# File lib/AttributeBase.rb, line 75 75: def name 76: type.name 77: end
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 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
# 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
# File lib/AttributeBase.rb, line 129 129: def to_rti(query) 130: @value.is_a?(RichTextIntermediate) ? !value : nil 131: end
Return the value as String.
# File lib/AttributeBase.rb, line 106 106: def to_s(query = nil) 107: @value.to_s 108: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.