Class: Y2Network::RoutingTable

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, Yast2::Equatable
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

Returns a new instance of RoutingTable.



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

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

Instance Attribute Details

#routesArray<Route> (readonly)

Returns Routes included in the table.

Returns:

  • (Array<Route>)

    Routes included in the table



39
40
41
# File 'src/lib/y2network/routing_table.rb', line 39

def routes
  @routes
end

Instance Method Details

#remove_default_routesObject

Returns the default route



50
51
52
# File 'src/lib/y2network/routing_table.rb', line 50

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