Class: RIB
- Inherits:
-
Object
- Object
- RIB
- Defined in:
- lib/netutils/rib.rb
Defined Under Namespace
Classes: Route
Instance Method Summary collapse
- #add(proto, dst, nh, interface) ⇒ Object
- #get(dst, proto = nil) ⇒ Object
-
#initialize ⇒ RIB
constructor
A new instance of RIB.
Constructor Details
#initialize ⇒ RIB
Returns a new instance of RIB.
63 64 65 |
# File 'lib/netutils/rib.rb', line 63 def initialize @rib = [] end |
Instance Method Details
#add(proto, dst, nh, interface) ⇒ Object
67 68 69 |
# File 'lib/netutils/rib.rb', line 67 def add(proto, dst, nh, interface) @rib.push(Route.new(proto, dst, nh, interface)) end |
#get(dst, proto = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/netutils/rib.rb', line 71 def get(dst, proto = nil) m = [] @rib.each do |r| next if proto && r.proto != proto m.push(r) if IPAddr.new(r.dst).include?(dst) end return nil if m.empty? return m end |