class RHC::Commands::ForwardingSpec

Attributes

bound[W]
host_from[R]
port_from[RW]

class to represent how SSH port forwarding should be performed

port_to[R]
remote_host[R]
service[R]

Public Class Methods

new(service, remote_host, port_to, port_from = nil) click to toggle source
# 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

Public Instance Methods

<=>(other) click to toggle source

: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
bound?() click to toggle source
# File lib/rhc/commands/port_forward.rb, line 32
def bound?
  @bound
end
to_cmd_arg() click to toggle source
# 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
to_fwd_args() click to toggle source
# 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