Skip to content

learn-co-curriculum/phase-3-ruby-oo-basics-email-parser-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bonus: Email Parser Lab

Learning Goals

  • Build a class that uses an initialize method
  • Practice using an attribute accessor macro to make an attribute available to a class's methods
  • Learn about Ruby's String.split method
  • Learn about RegEx

Description

You will write a program that, given a string of email addresses, parses that string into an array.

Your class, EmailAddressParser, should take the string of addresses on initialization. Instances should respond to a #parse instance method that parses the string into individual email addresses and returns them in an array.

Your class should be able to do this:

email_addresses = "[email protected], [email protected]"
parser = EmailAddressParser.new(email_addresses)

parser.parse
# => ["[email protected]", "[email protected]"]

Note: Your EmailAddressParser class should handle a list of email addresses that are separated by either spaces or comma-separated values (CSVs):

EmailAddressParser.new("[email protected], [email protected]").parse
# => ["[email protected]", "[email protected]"]

EmailAddressParser.new("[email protected] [email protected]").parse
# => ["[email protected]", "[email protected]"]

Additionally, the #parse method should only return unique addresses.

Instructions

This lab is test-driven, so run the test suite to get started and use the test output to get the program working.

Hints: in order to get this lab passing, you will need to do some research into the following topics:

  • Ruby's String.split method
  • RegEx - you'll use this to specify which characters to split the string on
  • Look at the Ruby documentation for the Array class. What method could be used to return an array of unique values?

Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages