Class: JunosConfig::Security::AddressBook
- Inherits:
-
Object
- Object
- JunosConfig::Security::AddressBook
- Defined in:
- lib/junos-config/security/addressbook.rb
Instance Attribute Summary collapse
-
#address_sets ⇒ Object
Returns the value of attribute address_sets.
-
#addresses ⇒ Object
Returns the value of attribute addresses.
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(config, raw) ⇒ AddressBook
constructor
A new instance of AddressBook.
- #lookup(name) ⇒ Object
- #resolve(name) ⇒ Object
Constructor Details
#initialize(config, raw) ⇒ AddressBook
Returns a new instance of AddressBook.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/junos-config/security/addressbook.rb', line 10 def initialize(config, raw) @config = config @raw = raw @addresses = raw.scan(/^(\ {16}address \S+ \S+;)$/).collect do |x| Security::Address.new self, x[0] end @address_sets = raw.scan(/^(\ {16}address-set \S+ \{$.*?^\ {16}\})$/m).collect do |x| Security::AddressSet.new self, x[0] end @resolv = {} @addresses.each { |a| @resolv[a.name] = a } @address_sets.each do |as| @resolv[as.name] = as aset = as.lookup_addresses(self) aset.each{ |a| @resolv[a.name] = a } end end |
Instance Attribute Details
#address_sets ⇒ Object
Returns the value of attribute address_sets.
4 5 6 |
# File 'lib/junos-config/security/addressbook.rb', line 4 def address_sets @address_sets end |
#addresses ⇒ Object
Returns the value of attribute addresses.
4 5 6 |
# File 'lib/junos-config/security/addressbook.rb', line 4 def addresses @addresses end |
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/junos-config/security/addressbook.rb', line 4 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/junos-config/security/addressbook.rb', line 4 def name @name end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/junos-config/security/addressbook.rb', line 4 def raw @raw end |
Instance Method Details
#lookup(name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/junos-config/security/addressbook.rb', line 32 def lookup(name) addrs = resolve(name) return unless addrs return addrs.addresses if addrs.class == JunosConfig::Security::AddressSet [addrs] end |
#resolve(name) ⇒ Object
28 29 30 |
# File 'lib/junos-config/security/addressbook.rb', line 28 def resolve(name) @resolv[name] end |