# File lib/shorturl.rb, line 37 def call(url) Net::HTTP.start(@hostname, @port) { |http| response = case @method when :post: http.post(@action, "#{@field}=#{url}") when :get: http.get("#{@action}?#{@field}=#{CGI.escape(url)}") end if response.code == @code.to_s @block.call(response.read_body) end } end