Class: Y2Network::Route

Inherits:
Object
  • Object
show all
Defined in:
src/lib/y2network/route.rb

Overview

This class represents a network route

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to: :default, interface: nil, gateway: nil, options: "") ⇒ Route

Returns a new instance of Route.

Parameters:

  • to (IPAddr, :default) (defaults to: :default)

    Destination

  • interface (Interface, nil) (defaults to: nil)

    Interface to associate the root to

  • gateway (IPAddr, nil) (defaults to: nil)

    Gateway IP

  • options (String) (defaults to: "")

    Additional options


35
36
37
38
39
40
# File 'src/lib/y2network/route.rb', line 35

def initialize(to: :default, interface: nil, gateway: nil, options: "")
  @to = to
  @interface = interface
  @gateway = gateway
  @options = options
end

Instance Attribute Details

#gatewayIPAddr?

Returns Gateway IP address ('via' in ip route).

Returns:

  • (IPAddr, nil)

    Gateway IP address ('via' in ip route)


27
28
29
# File 'src/lib/y2network/route.rb', line 27

def gateway
  @gateway
end

#interfaceInterface?

Returns Interface to associate the route to.

Returns:

  • (Interface, nil)

    Interface to associate the route to


25
26
27
# File 'src/lib/y2network/route.rb', line 25

def interface
  @interface
end

#optionsString

Returns Additional options.

Returns:

  • (String)

    Additional options


29
30
31
# File 'src/lib/y2network/route.rb', line 29

def options
  @options
end

#toIPAddr, :default

Returns Destination; :default if it is the default route.

Returns:

  • (IPAddr, :default)

    Destination; :default if it is the default route


23
24
25
# File 'src/lib/y2network/route.rb', line 23

def to
  @to
end

Instance Method Details

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

Determines whether two routes are equal

Parameters:

  • other (Route)

    Route to compare with

Returns:

  • (Boolean)

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

def ==(other)
  to == other.to && interface == other.interface && gateway == other.gateway &&
    options == other.options
end

#default?Boolean

Determines whether it is the default route or not

Returns:

  • (Boolean)

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

def default?
  to == :default
end