method
build
v2_6_3 -
Show latest stable
- Class:
URI::MailTo
build(args)public
Description
Creates a new URI::MailTo object from components, with syntax checking.
Components can be provided as an Array or Hash. If an Array is used, the components must be supplied as [to, headers].
If a Hash is used, the keys are the component names preceded by colons.
The headers can be supplied as a pre-encoded string, such as “subject=subscribe&cc=address”, or as an Array of Arrays like [[‘subject’, ‘subscribe’], [‘cc’, ‘address’]].
Examples:
require 'uri' m1 = URI::MailTo.build(['[email protected]', 'subject=Ruby']) m1.to_s # => "mailto:[email protected]?subject=Ruby" m2 = URI::MailTo.build(['[email protected]', [['Subject', 'Ruby'], ['Cc', '[email protected]']]]) m2.to_s # => "mailto:[email protected]?Subject=Ruby&[email protected]" m3 = URI::MailTo.build({:to => '[email protected]', :headers => [['subject', 'subscribe']]}) m3.to_s # => "mailto:[email protected]?subject=subscribe"