Method: URI::MailTo#to_mailtext
- Defined in:
- lib/uri/mailto.rb
#to_mailtext ⇒ Object Also known as: to_rfc822text
Returns the RFC822 e-mail text equivalent of the URL, as a String.
Example:
require 'uri'
uri = URI.parse("mailto:[email protected]?Subject=subscribe&cc=myaddr")
uri.to_mailtext
# => "To: [email protected]\nSubject: subscribe\nCc: myaddr\n\n\n"
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/uri/mailto.rb', line 268 def to_mailtext to = URI.decode_www_form_component(@to) head = '' body = '' @headers.each do |x| case x[0] when 'body' body = URI.decode_www_form_component(x[1]) when 'to' to << ', ' + URI.decode_www_form_component(x[1]) else head << URI.decode_www_form_component(x[0]).capitalize + ': ' + URI.decode_www_form_component(x[1]) + "\n" end end "To: #{to} #{head} #{body} " end |