Class: Net::Text::Generic
- Inherits:
-
Object
- Object
- Net::Text::Generic
- Defined in:
- lib/net/text/generic.rb
Overview
Generic interface to be used by specific network protocol implementation.
Class Method Summary collapse
Class Method Details
.build_uri(string_or_uri, uri_class) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/net/text/generic.rb', line 19 def self.build_uri(string_or_uri, uri_class) string_or_uri = URI(string_or_uri) if string_or_uri.is_a?(String) return string_or_uri if string_or_uri.is_a?(uri_class) raise ArgumentError, "uri is not a String, nor an #{uri_class.name}" end |
.request(uri, query) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/net/text/generic.rb', line 9 def self.request(uri, query) sock = TCPSocket.new(uri.host, uri.port) sock.puts query sock.read ensure # Stop remaining connection, even if they should be already cut # by the server sock&.close end |