Class: IPAddrList

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

Overview

SYNOPSIS

require 'ipaddr_list'
list = IPAddrList.new(['192.168.2.3/24', '192.168.0.100/24'], :BinarySearch)
list.add('192.168.1.100/24')
list.include?('192.168.0.30') #=> true

Defined Under Namespace

Modules: Algorithm

Instance Method Summary collapse

Constructor Details

#initialize(ip_list, algorithm = IPAddrList::Algorithm::BinarySearch) ⇒ IPAddrList

Returns a new instance of IPAddrList.



169
170
171
172
173
174
175
176
# File 'lib/ipaddr_list.rb', line 169

def initialize ip_list, algorithm=IPAddrList::Algorithm::BinarySearch
  unless algorithm.kind_of? Module
    algorithm = IPAddrList::Algorithm.const_get(algorithm.to_s)
  end
  self.extend(algorithm)
  @algorithm = algorithm
  after_init ip_list
end