Class: Reyes::IPSetBuilder

Inherits:
Object
  • Object
show all
Includes:
Chalk::Log
Defined in:
lib/reyes/ipset.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

TYPE =
"hash:ip"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ IPSetBuilder

Constructor for ipsets, maintaining the invariant that once constructed, ipsets will not be altered.

Parameters:

  • name (String)

    of the IPSet to create



12
13
14
15
# File 'lib/reyes/ipset.rb', line 12

def initialize(name)
  @name = name
  @members = []
end

Instance Attribute Details

#membersObject (readonly)

Returns the value of attribute members.



4
5
6
# File 'lib/reyes/ipset.rb', line 4

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/reyes/ipset.rb', line 4

def name
  @name
end

Instance Method Details

#<<(entity) ⇒ Object

Add a new member to this set. ‘member` should be something an ipset can understand, eg an ip address or cidr range

Parameters:

  • entity (String)

    to add to the set



20
21
22
# File 'lib/reyes/ipset.rb', line 20

def <<(entity)
  @members << entity
end

#buildObject

Builds the ipset, retuning an IPSet



26
27
28
29
30
31
# File 'lib/reyes/ipset.rb', line 26

def build
  log.info("Building ipset #{@name.inspect}")
  create
  populate
  IPSet.load(@name)
end