Class: Utils::SshTunnelSpecification
- Defined in:
- lib/utils/ssh_tunnel_specification.rb
Instance Attribute Summary collapse
-
#local_addr ⇒ String?
readonly
Returns the local address component of the SSH tunnel specification.
-
#local_port ⇒ Integer?
readonly
Returns the local port component of the SSH tunnel specification.
-
#remote_addr ⇒ String?
readonly
Returns the remote address component of the SSH tunnel specification.
-
#remote_port ⇒ Integer?
readonly
Returns the remote port component of the SSH tunnel specification.
Instance Method Summary collapse
-
#initialize(spec_string) ⇒ SshTunnelSpecification
constructor
Initializes a new SshTunnelSpecification instance by parsing the provided specification string.
-
#to_a ⇒ Array<String, Integer, String, Integer>
Returns an array representation of the SSH tunnel specification.
-
#to_s ⇒ String
Returns a string representation of the SSH tunnel specification.
-
#valid? ⇒ String?
Checks if all components of the SSH tunnel specification are present and valid.
Constructor Details
#initialize(spec_string) ⇒ SshTunnelSpecification
Initializes a new SshTunnelSpecification instance by parsing the provided specification string.
This method takes a specification string and extracts local and remote address/port combinations to configure the SSH tunnel parameters. The specification can take various formats including port-only specifications, localhost mappings, and full address:port combinations.
tunnel configuration
13 14 15 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 13 def initialize(spec_string) interpret_spec(spec_string) end |
Instance Attribute Details
#local_addr ⇒ String? (readonly)
Returns the local address component of the SSH tunnel specification.
20 21 22 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 20 def local_addr @local_addr end |
#local_port ⇒ Integer? (readonly)
Returns the local port component of the SSH tunnel specification.
25 26 27 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 25 def local_port @local_port end |
#remote_addr ⇒ String? (readonly)
Returns the remote address component of the SSH tunnel specification.
30 31 32 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 30 def remote_addr @remote_addr end |
#remote_port ⇒ Integer? (readonly)
Returns the remote port component of the SSH tunnel specification.
35 36 37 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 35 def remote_port @remote_port end |
Instance Method Details
#to_a ⇒ Array<String, Integer, String, Integer>
Returns an array representation of the SSH tunnel specification.
This method combines the local and remote address/port components into a four-element array in the order: [local_addr, local_port, remote_addr, remote_port].
44 45 46 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 44 def to_a [ local_addr, local_port, remote_addr, remote_port ] end |
#to_s ⇒ String
Returns a string representation of the SSH tunnel specification.
This method combines the local address, local port, remote address, and remote port components into a single colon-separated string format.
71 72 73 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 71 def to_s to_a * ':' end |
#valid? ⇒ String?
Checks if all components of the SSH tunnel specification are present and valid.
This method verifies that all address and port components of the tunnel configuration have been set. If all components are present, it returns the string representation of the specification; otherwise, it returns nil.
58 59 60 61 62 |
# File 'lib/utils/ssh_tunnel_specification.rb', line 58 def valid? if to_a.all? to_s end end |