class Puffy::Formatters::Base::Rule
Protected Instance Methods
emit_address(host)
click to toggle source
Return a string representation of the host
IPAddr as a host or network. @param host [IPAddr] @return [String] IP address
# File lib/puffy/formatters/base.rb, line 74 def emit_address(host) if (host.ipv4? && host.prefix.to_i == 32) || (host.ipv6? && host.prefix.to_i == 128) host.to_s else "#{host}/#{host.prefix}" end end
emit_port(port)
click to toggle source
Return a string representation of the port
port. param port [Integer,Range] @return [String] Port
# File lib/puffy/formatters/base.rb, line 85 def emit_port(port) case port when Integer then port.to_s when Range then "#{port.begin}:#{port.end}" else raise "Unexpected #{port.class.name}" end end
loopback_address(address_family)
click to toggle source
Returns the loopback IPAddr of the given address_family
@param address_family [Symbol] the address family, :inet
or :inet6
@return [IPAddr,nil]
# File lib/puffy/formatters/base.rb, line 62 def loopback_address(address_family) case address_family when nil then nil when :inet then Puffy::Formatters::Base.loopback_ipv4 when :inet6 then Puffy::Formatters::Base.loopback_ipv6 else raise "Unsupported address family #{address_family.inspect}" end end