module Ronin::CLI::HostAndPort
Mixin which adds methods for parsing ‘host:port` pairs.
Public Instance Methods
host_and_port(string)
click to toggle source
Parses a ‘host:port` pair.
@param [String] string
The string containing the `host:port` pair.
@return [(String, Integer)]
The parsed host and port.
# File lib/ronin/cli/host_and_port.rb, line 36 def host_and_port(string) host, port = string.split(':',2) return host, port.to_i end
host_and_port_from_url(url)
click to toggle source
Parses the host and port from the given URL.
@param [String] url
The URL to parse.
@return [(String, Integer)]
The host and port components of the URL.
# File lib/ronin/cli/host_and_port.rb, line 51 def host_and_port_from_url(url) uri = Addressable::URI.parse(url) return uri.normalized_host, uri.inferred_port end