Validating a Collection of IPv4s I have a method within a class that validates all proxy addresses are valid on initialization. I've tried to refactor this a bit, but this seems to be the best I can do. Any suggestions and/or tips as to how I can possibly improve this method?

def valid?(proxies)
  return false if !proxies.is_a?(Array) || proxies.empty?
  ipv4_address = /^((\d{1,3}[\.]){3}\d{1,3}:\d+)$/
  proxies.each do |proxy|
    return false if proxy !~ ipv4_address
    octets = proxy.scan(/\d+/).map(&amp;:to_i).first(4)
    return false unless octets.all? { |octet| octet.between?(0, 255) }
  end
  true
end
The only simplification I can think of is using a bit more complex regex to match the IP address without having to iterate over the octets:

def valid?(proxies)
  return false if !proxies.is_a?(Array) || proxies.empty?
  ipv4_address = /^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d):\d+$/
  proxies.each do |proxy|
    return false if proxy !~ ipv4_address
  end
  true
end


This regex is based on the one in the ipaddress package.