Ruby Problem Create a template for an email letterhead with
Ruby Problem
Create a template for an email letterhead with the following variables. The letter head will have format place holders for:
Company name
Street address
City, State and zip code
Telephone
Web site URL
Use the array of data below to fill your template place holders:
Run your finished script and capture the output to a file named email_template.txt.
Your output should end up looking something like this:
Solution
# Two pieces of data in one array (multi dimensional array)
contact_data = [
[\'Company 1\',\'123 Main Street\', \'Anytown\',\'Anystate\', 88888,\'444-444-4444\',\'CompanyOne@companyone.com\',\'https://company1.com\'],
[\'Company 2\',\'77 Market Street\', \'San Francisco\',\'California\', 94111,\'415-444-4444\',\'Company2@company2.com\',\'https://company2.com\']
]
######### CREATE YOUR EMAIL TEMPLATE HERE #########
email_template = \"\"
# Process the data one array at a time
contact_data.each do |arr|
puts arr[0]
puts arr[1]
puts arr[2] + \", \" + arr[3] + \" \" + arr[4].to_s
puts \"Tel: \" + arr[5]
puts \"Email: \" + arr[6]
puts \"URL: \" + arr[7]
puts \"\ ------------------------------\"
end
