Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 35 lines (30 sloc) 1.004 kb
a10421a @Watson1978 moved the files from MacRuby's repository
Watson1978 authored
1 class ABPerson
2
3 # Pull first and last name, organization, and record flags
4 # If the entry is a company, display the organization name instead
5 def displayName
6 firstName = valueForProperty KABFirstNameProperty
7 lastName = valueForProperty KABLastNameProperty
8 companyName = valueForProperty KABOrganizationProperty
9 flagsValue = valueForProperty KABPersonFlags
10
11 flags = flagsValue ? flagsValue.intValue : 0
12 if (flags & KABShowAsMask) == KABShowAsCompany
13 return companyName if companyName and companyName.length > 0
14 end
15
16 lastNameFirst = (flags & KABNameOrderingMask) == KABLastNameFirst
17 hasFirstName = firstName and firstName.length > 0
18 hasLastName = lastName and lastName.length > 0
19
20 if hasLastName and hasFirstName
21 if lastNameFirst
22 "#{lastName} #{firstname}"
23 else
24 "#{firstName} #{lastName}"
25 end
26 elsif hasLastName
27 lastName
28 elsif hasFirstName
29 firstName
30 else
31 'n/a'
32 end
33 end
34
35 end
Something went wrong with that request. Please try again.