Class: Xrc::Connection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
9
# File 'lib/xrc/connection.rb', line 5

def initialize(options, &block)
  @domain = options[:domain]
  @port = options[:port]
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/xrc/connection.rb', line 3

def block
  @block
end

#domainObject (readonly)

Returns the value of attribute domain.



3
4
5
# File 'lib/xrc/connection.rb', line 3

def domain
  @domain
end

#portObject (readonly)

Returns the value of attribute port.



3
4
5
# File 'lib/xrc/connection.rb', line 3

def port
  @port
end

#socketObject (readonly)

Returns the value of attribute socket.



3
4
5
# File 'lib/xrc/connection.rb', line 3

def socket
  @socket
end

Instance Method Details

#connectObject



11
12
13
14
# File 'lib/xrc/connection.rb', line 11

def connect
  @socket = Connector.connect(domain: domain, port: port)
  start
end

#encryptObject



16
17
18
19
# File 'lib/xrc/connection.rb', line 16

def encrypt
  @socket = TslConnector.connect(socket: socket)
  start
end

#openObject



21
22
23
# File 'lib/xrc/connection.rb', line 21

def open
  write Elements::Stream.new(domain: domain)
end

#write(object) ⇒ Object



25
26
27
# File 'lib/xrc/connection.rb', line 25

def write(object)
  socket << object.to_s
end