forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtoString.as
More file actions
36 lines (35 loc) · 865 Bytes
/
toString.as
File metadata and controls
36 lines (35 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package utils.object
{
/**
* Convert the object to a string of form: <code>PROP: VAL&PROP: VAL</code>
* where:
* <ul>
* <li><code>PROP</code> is a property</li>
* <li><code>VAL</code> is its corresponding value</li>
* <li>& is the specified optional delimiter</li>
* </ul>
*
* @param obj Object to convert
* @param delimiter (optional) Delimiter of property/value pairs
* @return An string of all property/value pairs delimited by the
* given string or null if the input object or delimiter is
* null.
* @author Jackson Dunstan
*/
public function toString(obj:Object = null, delimiter:String = "\n"):String
{
if (obj == null || delimiter == null)
{
return "";
}
else
{
var ret:Array = [];
for (var s:Object in obj)
{
ret.push(s + ": " + obj[s]);
}
return ret.join(delimiter);
}
}
}