Class: Xrc::Connection
- Inherits:
-
Object
- Object
- Xrc::Connection
- Defined in:
- lib/xrc/connection.rb,
lib/xrc/connection/connector.rb,
lib/xrc/connection/tsl_connector.rb
Defined Under Namespace
Classes: Connector, TslConnector
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #connect ⇒ Object
- #encrypt ⇒ Object
-
#initialize(options, &block) ⇒ Connection
constructor
A new instance of Connection.
- #open ⇒ Object
- #write(object) ⇒ Object
Constructor Details
#initialize(options, &block) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 10 |
# File 'lib/xrc/connection.rb', line 5 def initialize(, &block) @domain = [:domain] @hosts = [:hosts] @port = [:port] @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/xrc/connection.rb', line 3 def block @block end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
3 4 5 |
# File 'lib/xrc/connection.rb', line 3 def domain @domain end |
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
3 4 5 |
# File 'lib/xrc/connection.rb', line 3 def hosts @hosts end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/xrc/connection.rb', line 3 def port @port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
3 4 5 |
# File 'lib/xrc/connection.rb', line 3 def socket @socket end |
Instance Method Details
#connect ⇒ Object
12 13 14 15 |
# File 'lib/xrc/connection.rb', line 12 def connect @socket = Connector.connect(domain: domain, hosts: hosts, port: port) start end |
#encrypt ⇒ Object
17 18 19 20 |
# File 'lib/xrc/connection.rb', line 17 def encrypt @socket = TslConnector.connect(socket: socket) start end |
#open ⇒ Object
22 23 24 |
# File 'lib/xrc/connection.rb', line 22 def open write Elements::Stream.new(domain: domain) end |
#write(object) ⇒ Object
26 27 28 |
# File 'lib/xrc/connection.rb', line 26 def write(object) socket << object.to_s end |