Sha256: 6d8b151a656d7b68589aa6774257dc943ff2ae9d2512318b162c6bf93a545642

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

class VRFTable
	include Enumerable
	class VRF
		attr_reader :name, :rd, :interfaces
		def initialize(name, rd)
			@name  = name
			@rd    = rd if rd =~ /[0-9]+:[0-9]/
			@interfaces = []
		end

		def interface_add(ifname)
			@interfaces.push(ifname)
		end

		def to_s
			return "#{@name} (#{@rd})"
		end
	end

	def initialize
		@table = {}
	end

	def add(name, rd)
		vrf = VRF.new(name, rd)
		@table[name] = vrf
		return vrf
	end

	def [](name)
		return @table[name]
	end
	private :[]

	def empty?
		@table.empty?
	end

	def each
		@table.each { |vrf| yield vrf }
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netutils-0.1.2 lib/netutils/vrf.rb
netutils-0.1.1 lib/netutils/vrf.rb