Method: IPAccess::List#grep_exact

Defined in:
lib/ipaccess/ip_access_list.rb

#grep_exact(*addresses) ⇒ Object

This method finds all addresses in the list that are equal to given addresses/netmasks and returns an array containing these addresses. It is intended to be used to operate on lists rather than to match IPs to them.

If the optional block is supplied, each matching element is passed to it, and the block‘s result is stored in the output array.

See IPAccess.to_cidrs description for more info about arguments you may pass to it.



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/ipaccess/ip_access_list.rb', line 161

def grep_exact(*addresses)
  return [] if empty?
  out_ary = []
  addrs = IPAccess.to_cidrs(*addresses)
  addrs.each do |addr|
    m = included_cidr(addr)
    if (m == addr)
      out_ary.push( block_given? ? yield(m) : m)
    end
  end
  return out_ary
end