def truncate_email(email, options = {})
      return "" unless email.match(/@/)
      split_email = email.split('@')
      omission = options[:omission] || "…"
      local_part = "#{split_email.first.first}#{omission}"
      domain = options[:truncate_domain] ? "#{split_email.last.first}#{omission}" : split_email.last
      "#{local_part}@#{domain}"
    end
def truncate_email(email, options = {})
      return "" unless email.match(/@/)
      split_email = email.split('@')
      omission = options[:omission] || "…"
      local_part = "#{split_email.first.first}#{omission}"
      domain = options[:truncate_domain] ? "#{split_email.last.first}#{omission}" : split_email.last
      "#{local_part}@#{domain}"
    end
Truncates an email address, e.g.:

   truncate_email('example@example.com') # => e…@example.com
   truncate_email('example@example.com', truncate_domain: true) # => e…@e…

 ==== Options

 [:omission]

   The string to use in replacement of the removed characters.

 [:truncate_domain]

   Boolean. Whether to truncate the domain part of the address as well.