Class: Cidr::Aggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/cidr/aggregator.rb

Instance Method Summary collapse

Instance Method Details

#add(ip) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/cidr/aggregator.rb', line 82

def add (ip)
  case ip.class.to_s
  when 'String'
    return nil unless _store_ipaddr_str (ip)
  when 'Fixnum'
    return nil unless _store_ipaddr_int (ip)
  else
    return nil
  end
end

#listObject



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cidr/aggregator.rb', line 93

def list
  _aggregate
  return_addrs = Array.new
  
  for i in 0..31 do
    @addr_pool[i].each {|ipaddr|
      return_addrs.push ({:addr => IPAddr.new(ipaddr,Socket::AF_INET).to_s,
                           :prefix => 32-i})
    }
  end
  return_addrs
end