Sha256: 99318b6912d16c695b9783c1ef24888aaec3946b68c3dea153384b298eb902bf

Contents?: true

Size: 481 Bytes

Versions: 1

Compression:

Stored size: 481 Bytes

Contents

module Vmail
  module AddressQuoter

    def quote_addresses(input)
      parts = input.split /\s*,\s*/

      addrs = []
      savebin = ""

      #Group the parts together
      parts.each do |part|
        if part.include? "@"
          addrs << savebin + part
          savebin = ""
        else
          savebin = part + ", "
        end
      end
      
      #Quote the names
      addrs.map { |addr| addr.gsub(/^(.*) (<.*)/, '"\1" \2') }.join(', ')
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vmail-1.3.5 lib/vmail/address_quoter.rb