Class: Y2Network::RoutingTable

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
src/lib/y2network/routing_table.rb

Overview

Represents a routing table

Examples:

Adding routes

table = Y2Network::RoutingTable.new
route = Y2Network::Route.new(to: IPAddr.new("192.168.122.0/24"))
table << route

Iterating through routes

table.map { |r| r.to } #=> [<IPAddr: IPv4:192.168.122.0/255.255.255.0>]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(routes = []) ⇒ RoutingTable


41
42
43
# File 'src/lib/y2network/routing_table.rb', line 41

def initialize(routes = [])
  @routes = routes
end

Instance Attribute Details

#routesArray<Route> (readonly)


37
38
39
# File 'src/lib/y2network/routing_table.rb', line 37

def routes
  @routes
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Determines whether two routing tables are equal


54
55
56
# File 'src/lib/y2network/routing_table.rb', line 54

def ==(other)
  routes == other.routes
end

#remove_default_routesObject

Returns the default route


46
47
48
# File 'src/lib/y2network/routing_table.rb', line 46

def remove_default_routes
  @routes.reject!(&:default?)
end