Module: Vmail::AddressQuoter
- Included in:
- ImapClient
- Defined in:
- lib/vmail/address_quoter.rb
Instance Method Summary collapse
Instance Method Details
#quote_addresses(input) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vmail/address_quoter.rb', line 4 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| # a little hackish if addr =~ /"/ addr else addr.gsub(/^(.*) (<.*)/, '"\1" \2') end }.join(', ') end |