class AttributeDictionary |
Parent: Object |
|
Methods: [], []=,
delete_key,
|
|
Sample Code: attrdicttests.rb |
|
Instance Methods |
[] |
The get value method is used to retrieve the attribute with a given key. |
Syntax: |
value = attributedictionary ["key"] |
Arguments: |
"key" - the name of the attribute |
Return Value: |
value - the value associated with the "key" if successful |
Comments: |
|
Example: |
model = Sketchup.active_model if (attrdict) |
[]= |
The set value ([]=) method is used to set the value of an attribute with a given key. |
Syntax: |
value = attributedictionary[“key"]=value |
Arguments: |
“key” – the valid key value – the value to be set |
Return Value: |
value – the value that was set if successful, or false if unsuccessful. |
Comments: |
Creates a new attribute for the given key if needed. |
Example: |
model = Sketchup.active-model else |
delete_key |
The delete_key method is used to delete an attribute with a given key. |
Syntax: |
value = attributedictionary.delete_key “key” |
Arguments: |
“key” – the key to be deleted |
Return Value: |
value – the value of the key that was deleted if successful |
Comments: |
|
Example: |
attrdict = attrdicts[“testdictionary”] value = attrdict.delete_key(“testkey”) |
each |
The each method is used to iterate through all of the attributes. |
Syntax: |
attributedictionary.each { | key, value | … } |
Arguments: |
key, value – variables that will hold each key and value as they are found. |
Return Value: |
|
Comments: |
Throws an exception if there are no keys. |
Example: |
dictionaries = model.attribute_dictionaries # iterates through all attributes and
prints the key to the screen |
each_key |
The each_key method is used to iterate through all of the attribute keys. |
Syntax: |
attributedictionary.each { | key | … } |
Arguments: |
key– a variable that will hold each key as they are found. |
Return Value: |
|
Comments: |
Throws an exception if there are no keys. |
Example: |
dictionaries = model.attribute_dictionaries # iterates through all attributes and
prints the key to the screen |
each_pair |
An alias for each. See AttributeDictionary.each |
Syntax: |
attributedictionary.each_pair {|key, value | ...} |
Arguments: |
key, value – variables that will hold each key and value as they are found. |
Return Value: |
|
Comments: |
Throws an exception if there are no keys. |
Example: |
dictionaries = model.attribute_dictionaries # iterates through all attributes and
prints the key to the screen |
keys |
The keys method is used to retrieve an array with all of the attribute keys. |
Syntax: |
keys = attributedictionary.keys |
Arguments: |
|
Return Value: |
keys – an array of keys within the attribute dictionary if successful |
Comments: |
|
Example: |
keys = attrdict.keys if (keys) |
length |
An alias for size. See AttributeDictionary.size. |
Syntax: |
length = attributedictionary.length |
Arguments: |
|
Return Value: |
length – the length (size) of the attribute dictionary. |
Comments: |
|
Example: |
length = attrdict.length if (length) |
name |
The name method is used to retrieve the name of an attribute dictionary. |
Syntax: |
name = attributedictionary.name |
Arguments: |
|
Return Value: |
name – the name of the attribute dictionary if successful |
Comments: |
|
Example: |
name = attrdict.name if (name) |
size |
The length method is used to retrieve the size (number of elements) of an attribute dictionary. |
Syntax: |
size = attributedictionary.size |
Arguments: |
|
Return Value: |
size – the size of the attribute dictionary if successful |
Comments: |
|
Example: |
size = attrdict.size if (size) |
values |
The values method is used to retrieve an array of all of the attribute values. |
Syntax: |
values = attributedictionary.values |
Arguments: |
|
Return Value: |
values – an array of values within the attribute dictionary if successful |
Comments: |
|
Example: |
values = attrdict.values if (values) |