Class: RBus::Transport::AbstractTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/rbus/bus/transport.rb

Overview

Abstract base implementation of a transport.

Direct Known Subclasses

TCPTransport, UNIXTransport

Constant Summary collapse

CRLF =

Newline

"\015\012"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_info) ⇒ AbstractTransport

Returns a new instance of AbstractTransport.



40
41
42
43
# File 'lib/rbus/bus/transport.rb', line 40

def initialize(connection_info)
  @connection_info = connection_info
  create_socket
end

Instance Attribute Details

#socketObject (readonly)

Returns the value of attribute socket.



38
39
40
# File 'lib/rbus/bus/transport.rb', line 38

def socket
  @socket
end

Instance Method Details

#closeObject



62
63
64
# File 'lib/rbus/bus/transport.rb', line 62

def close
  @socket.close
end

#read(len = 2**27) ⇒ Object



49
50
51
52
# File 'lib/rbus/bus/transport.rb', line 49

def read(len = 2**27)
  @socket.read(len)
  #@socket.recv(len)
end

#readlineObject



58
59
60
# File 'lib/rbus/bus/transport.rb', line 58

def readline
  @socket.readline.chomp
end

#send(message) ⇒ Object



45
46
47
# File 'lib/rbus/bus/transport.rb', line 45

def send(message)
  @socket.write(message)
end

#sendline(message) ⇒ Object



54
55
56
# File 'lib/rbus/bus/transport.rb', line 54

def sendline(message)
  @socket.write(message + CRLF)        
end