Class: RIO::TCP::RL

Inherits:
RL::IOIBase
  • Object
show all
Defined in:
lib/rio/scheme/tcp.rb

Constant Summary collapse

RIOSCHEME =
'tcp'.freeze
SPLIT_RE =

must be able to process parse(‘rio:tcp’,host,port) parse(‘rio:tcp://host:port’)

%r|//([^/:]*):([0-9a-z]+)$|.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ RL

Returns a new instance of RL.



45
46
47
48
49
# File 'lib/rio/scheme/tcp.rb', line 45

def initialize(host,port)
  @host = host
  @port = port
  super
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



44
45
46
# File 'lib/rio/scheme/tcp.rb', line 44

def host
  @host
end

Class Method Details

.splitrl(s) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/rio/scheme/tcp.rb', line 64

def self.splitrl(s)
  sub,opq,whole = split_riorl(s)
  if bm = SPLIT_RE.match(opq)
    host = bm[1]
    port = bm[2]
    host = nil if host.empty?
    [host,port]
  end
end

Instance Method Details

#opaqueObject



50
51
52
# File 'lib/rio/scheme/tcp.rb', line 50

def opaque()
  sprintf('//%s:%s',@host,@port)
end

#open(*args) ⇒ Object



54
55
56
57
# File 'lib/rio/scheme/tcp.rb', line 54

def open(*args)
  #          @host = 'localhost' if @host.nil? or @host.empty?
  super(::TCPSocket.new(@host || 'localhost',@port))
end

#to_sObject



58
# File 'lib/rio/scheme/tcp.rb', line 58

def to_s() self.url end