Created
August 27, 2013 14:16
-
-
Save radavis/6354100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| salutations = [['Mr.', 'Mrs.'], 'Mrs.', ['Mr.', 'Mrs.'], ['Dr.'], 'Ms.'] | |
| first_names = ['John', 'Jane', 'Sam', 'Louise', 'Kyle'] | |
| last_names = ['Dillinger', 'Cook', 'Livingston', 'Levinger', 'Merlotte'] | |
| addresses = ['33 Foolish Lane, Boston, MA 02210', | |
| '45 Cottage Way, Dartmouth, MA 02342', | |
| "54 Sally's Court, Bridgewater, MA 02324", | |
| '4534 Broadway, Boston, MA 02110', | |
| '4231 Cynthina Drive, Raynham, MA 02767'] | |
| mail_list = [] | |
| salutations.size.times do | |
| addr = {} | |
| salutation = salutations.pop | |
| if salutation.class == Array | |
| addr[:salutation] = salutation.join(' & ') | |
| else | |
| addr[:salutation] = salutation | |
| end | |
| addr[:first_name] = first_names.pop | |
| addr[:last_name] = last_names.pop | |
| addr[:address] = addresses.pop | |
| mail_list << addr | |
| end | |
| mail_list.reverse.each do |addr| | |
| full_address = '' | |
| addr.each_key do |k| | |
| full_address += "\n" if k == :address | |
| full_address += addr[k] + ' ' | |
| end | |
| puts full_address + "\n\n" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment