module Earl class URLAssembler def assemble( parts={} ) ''.tap do |url| url << ( parts[ :scheme ] + '://' ) if parts[ :scheme ] url << ( parts[ :subdomain ] + '.' ) if parts[ :subdomain ] url << ( parts[ :host ] ) if parts[ :host ] url << ( ':' + parts[ :port ].to_s ) if parts[ :port ] url << ( '/' + parts[ :path ] ) if parts[ :path ] url << ( '?' + parts[ :search ] ) if parts[ :search ] end end end end