class Utils::SshTunnelSpecification
def initialize(spec_string)
-
spec_string
(String
) -- the specification string defining the SSH
def initialize(spec_string) interpret_spec(spec_string) end
def interpret_spec(spec_string)
-
(Array
- an array containing the local address,)
Parameters:
-
spec_string
(String
) -- the specification string defining the SSH tunnel configuration
def interpret_spec(spec_string) @local_addr, @local_port, @remote_addr, @remote_port = case spec_string when /\A(\d+)\z/ [ 'localhost', $1.to_i, 'localhost', $1.to_i ] when /\A(\[[^\]]+\]|[^:]+):(\d+)\z/ [ 'localhost', $2.to_i, $1, $2.to_i ] when /\A(\d+):(\[[^\]]+\]|[^:]+):(\d+)\z/ [ 'localhost', $1.to_i, $2, $3.to_i ] when /\A(\[[^\]]+\]|[^:]+):(\[[^\]]+\]|[^:]+):(\d+)\z/ [ $1, $3.to_i, $2, $3.to_i ] when /\A(\[[^\]]+\]|[^:]+):(\d+):(\[[^\]]+\]|[^:]+):(\d+)\z/ [ $1, $2.to_i, $3, $4.to_i ] end end
def to_a
-
(Array
- an array containing the)
def to_a [ local_addr, local_port, remote_addr, remote_port ] end
def to_s
-
(String)
- a colon-separated string containing the tunnel specification
def to_s to_a * ':' end
def valid?
-
(String, nil)
- the string representation of the specification if all
def valid? if to_a.all? to_s end end