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
10
# File 'lib/xrc/connection.rb', line 5

def initialize(options, &block)
  @domain = options[:domain]
  @hosts = options[:hosts]
  @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

#hostsObject (readonly)

Returns the value of attribute hosts.



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

def hosts
  @hosts
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



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

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

#encryptObject



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

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

#openObject



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