Class: Weso::Base::SocketCreator
- Inherits:
-
Object
- Object
- Weso::Base::SocketCreator
- Defined in:
- lib/weso/socket_creator.rb
Overview
- ::nodoc
Constant Summary collapse
- DEFAULT_SSL_VERSION =
'SSLv23'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(url, options) ⇒ SocketCreator
constructor
A new instance of SocketCreator.
- #secure? ⇒ Boolean
Constructor Details
#initialize(url, options) ⇒ SocketCreator
Returns a new instance of SocketCreator.
11 12 13 14 |
# File 'lib/weso/socket_creator.rb', line 11 def initialize(url, ) @uri = URI.parse(url) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/weso/socket_creator.rb', line 7 def @options end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/weso/socket_creator.rb', line 7 def uri @uri end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 |
# File 'lib/weso/socket_creator.rb', line 16 def call socket = TCPSocket.new(uri.host, port) socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) socket = process_secure(socket) if secure? socket end |
#secure? ⇒ Boolean
23 24 25 |
# File 'lib/weso/socket_creator.rb', line 23 def secure? %w[https wss].include? uri.scheme end |