module Formatter

Public Instance Methods

normalize(content) click to toggle source
# File lib/cyrus-code-challenge/formatter.rb, line 3
def normalize(content)    
  dashed = content.gsub(/[-]/, "/")
  contact = dashed.gsub(/[,]|[|]/, "").split(" ")
  delete_middle_name(contact)
  switch_dates(contact)
  spell_gender(contact)
  contact
end

Private Instance Methods

delete_middle_name(content) click to toggle source
# File lib/cyrus-code-challenge/formatter.rb, line 14
def delete_middle_name(content)
  if content.length == 6 
    content.delete_at(2)
  end
end
spell_gender(contact) click to toggle source
# File lib/cyrus-code-challenge/formatter.rb, line 26
def spell_gender(contact)
  if contact[2] == "M"
    contact[2] = "Male"
  elsif contact[2] == "F"
    contact[2] = "Female"
  else
    contact
  end
end
switch_dates(content) click to toggle source
# File lib/cyrus-code-challenge/formatter.rb, line 20
def switch_dates(content)
  if content[3].include?("/")
    content[3], content[4] = content[4], content[3]
  end
end