Question

In: Computer Science

Ruby Problem Create a template for an email letterhead with the following variables. The letter head...

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

Email

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.

# Two pieces of data in one array (multi dimensional array)
contact_data = [
  ['Company 1','123 Main Street', 'Anytown','Anystate', 88888,'444-444-4444','[email protected]','https://company1.com'],
  ['Company 2','77 Market Street', 'San Francisco','California', 94111,'415-444-4444','[email protected]','https://company2.com']
]

######### CREATE YOUR EMAIL TEMPLATE HERE #########
email_template = ""

# Process the data one array at a time
contact_data.each do |arr|
   # your code goes here.
end

Your output should end up looking something like this:

  Company 1
  123 Main Street
  Anytown, Anystate 88888
  Tel: 444-444-4444
  Email: [email protected]
  URL: https://company1.com

------------------------------

  Company 2
  77 Market Street
  San Francisco, California 94111
  Tel: 415-444-4444
  Email: [email protected]
  URL: https://company2.com

------------------------------

Solutions

Expert Solution

Answer

# Two pieces of data in one array (multi dimensional array)
contact_data = [
['Company 1','123 Main Street', 'Anytown','Anystate', 88888,'444-444-4444','[email protected]','https://company1.com'],
['Company 2','77 Market Street', 'San Francisco','California', 94111,'415-444-4444','[email protected]','https://company2.com']
]

######### CREATE YOUR EMAIL TEMPLATE HERE #########
email_template = ""

# Process the data one array at a time
# Loop over each row array.
contact_data.each do |arr|
# Loop over each cell in the row.
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]
# End of row.
puts "----------------------------"
end

OUTPUT


Related Solutions

Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then...
Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then calculates the arithmetic mean (otherwise known as the average), the median (that is, the number that splits the set of value in half with half being above and half being below the number), and the standard deviation (that is, the average of distance each number is from the mean then squared). Further information about these calculations can be found here: average: http://en.wikipedia.org/wiki/Average (add up...
Must be done in Ruby Histogram Create a Ruby program which reads a string of information...
Must be done in Ruby Histogram Create a Ruby program which reads a string of information and uses a Hash to keep track of letter frequencies and then displays a Histogram using this frequency information. IN ORDER TO RECEIVE FULL CREDIT, YOUR CODE SHOULD PROPERLY PROCESS THE STRING INFORMATION, COUNTING FREQUENCIES BY USING A HASH. A number of different program dialogues describe the program I am looking for. Enter Data: supercalifragilisticexpialadocious A - 4 - **** C - 3 -...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What are the effects of modern technology on children?
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What are the effects of modern technology on children?
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter)...
Write a Cause and Effect Essay. Write a 500 word essay (not an email or letter) based on the writing prompt. Topic: What causes a person to become an excellent student?
Develop a promotional message. This can be an email, letter, or any other relevant material that...
Develop a promotional message. This can be an email, letter, or any other relevant material that answers why should students take a Professional Communications course.
Your Professional Experience assignment is to develop a promotional message. This can be an email, letter,...
Your Professional Experience assignment is to develop a promotional message. This can be an email, letter, info graphic, image, or any other relevant material that answers why should students take a Professional Communications course.
HTML WEBSITE WITH CSS LAYOUT 1. Create a studentregistration form with the following fields: > Email...
HTML WEBSITE WITH CSS LAYOUT 1. Create a studentregistration form with the following fields: > Email Address (Email) > Desired Username (Text box) > Password (Password) > Family name (Text box) > Middle Name/Initial (Text box) > First name (Text box) > Gender (Radio Button - Male or Female only!) > ID Number (Text box) > Mobile Number (Text box) > Landline Number (Text box) > Permanent Home Address (Text box) > Degree/Course (Text box) > Year Level (Drop down...
Task # 1: Create Network Diagrams for the following: sending a letter including the following activities:...
Task # 1: Create Network Diagrams for the following: sending a letter including the following activities: Write letter Put in envelope Address letter Place stamp on letter Post letter Provide the answer with explanation.
Excel HW 4: Fox Lake Networking Template Objective: Create a template to estimate the cost of...
Excel HW 4: Fox Lake Networking Template Objective: Create a template to estimate the cost of networking Fox Lake Country Club. Skills: IF, AND, OR, COUNT, COUNTA, and COUNTIF and Conditional formatting For the past year, members at Fox Lake Country Club have been complaining about not being able to access the Internet or slow data transmission speeds while at the club. Given your knowledge of spreadsheets, Jeff Lewis, business manager at Fox Lake, has asked you to create an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT