Retrieving Twitter account from Mac OS X Lion's Address Book via MacRuby

Software Engineering 2529 views

The code assumes Mac OS X 10.7. Also, the code could be represented differently (i.e. without using a Range) if ABMutableMultiValue behaved like a Ruby Array or supported .to_a

me = address_book.me
account = (0..me.socialProfile.count).each {|i| break me.socialProfile.valueAtIndex(i)['username'] if me.socialProfile.valueAtIndex(i)['serviceName'] == 'Twitter' } || me.nickname