From 695cc355f97fdbcf8c406f85be5a2c123e9c2b88 Mon Sep 17 00:00:00 2001 From: Liam Simmons Date: Thu, 11 Jul 2024 09:53:14 -0400 Subject: [PATCH] Create EmailAddressParser Class --- lib/email_parser.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/email_parser.rb b/lib/email_parser.rb index 4e0f7a62..f3f7df36 100644 --- a/lib/email_parser.rb +++ b/lib/email_parser.rb @@ -1,4 +1,14 @@ -# Build a class EmailAddressParser that accepts a string of unformatted +# Build a class EmailAddressParser that accepts a string of unformatted # emails. The parse method on the class should separate them into # unique email addresses. The delimiters to support are commas (',') # or whitespace (' '). + +class EmailAddressParser + def initialize(addresses) + @addresses = addresses + end + + def parse + @addresses.split(/[\s,]+/).uniq + end +end