class to represent how SSH port forwarding should be performed
# File lib/rhc/commands/port_forward.rb, line 13 def initialize(service, remote_host, port_to, port_from = nil) @service = service @remote_host = remote_host @port_to = port_to @host_from = '127.0.0.1' @port_from = port_from || port_to # match ports if possible @bound = false end
:nocov: These are for sorting. No need to test for coverage.
# File lib/rhc/commands/port_forward.rb, line 37 def <=>(other) if bound? && !other.bound? -1 elsif !bound? && other.bound? 1 else order_by_attrs(other, :service, :remote_host, :port_from) end end
# File lib/rhc/commands/port_forward.rb, line 32 def bound? @bound end
# File lib/rhc/commands/port_forward.rb, line 22 def to_cmd_arg # string to be used in a direct SSH command "-L #{port_from}:#{remote_host}:#{port_to}" end
# File lib/rhc/commands/port_forward.rb, line 27 def to_fwd_args # array of arguments to be passed to Net::SSH::Service::Forward#local [port_from.to_i, remote_host, port_to.to_i] end