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 ] ) if parts[ :port ] url << ( '/' + parts[ :path ] ) if parts[ :path ] url << ( '?' + parts[ :search ] ) if parts[ :search ] url end end end end