- 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
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.
I 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 commas. Additionally, the
parse
method should only return unique addresses.
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