class WebConsole::Permissions

def coerce_network_to_ipaddr(network)

def coerce_network_to_ipaddr(network)
  if network.is_a?(IPAddr)
    network
  else
    IPAddr.new(network)
  end
end

def human_readable_ipaddr(ipaddr)

def human_readable_ipaddr(ipaddr)
  ipaddr.to_range.to_s.split("..").uniq.join("/")
end

def include?(network)

def include?(network)
  @networks.any? { |permission| permission.include?(network.to_s) }
rescue IPAddr::InvalidAddressError
  false
end

def initialize(networks = nil)

def initialize(networks = nil)
  @networks = normalize_networks(networks).map(&method(:coerce_network_to_ipaddr)).uniq
end

def normalize_networks(networks)

def normalize_networks(networks)
  Array(networks).concat(ALWAYS_PERMITTED_NETWORKS)
end

def to_s

def to_s
  @networks.map(&method(:human_readable_ipaddr)).join(", ")
end