Class: Net::IP::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ip/rule.rb,
lib/net/ip/rule/parser.rb,
lib/net/ip/rule/collection.rb

Overview

Class for working with ip rules.

Defined Under Namespace

Classes: Collection, Parser

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Rule

Note:

This does NOT add the entry to the ip rules. See Net::IP::Rule::Collection#add for creating new rules in the ip rule list.

Create a new rule object

Examples:

Create a rule to use a different route table

Net::IP::Rule.new(:to => '1.2.3.4', :table => 'custom')

Parameters:

  • params (Hash) (defaults to: {})


10
11
12
13
14
# File 'lib/net/ip/rule.rb', line 10

def initialize(params = {})
  params.each do |k,v|
    instance_variable_set("@#{k}", v)
  end
end

Instance Method Details

#to_paramsObject



16
17
18
19
20
# File 'lib/net/ip/rule.rb', line 16

def to_params
  str = ""
  str << "priority #{@priority} " if @priority
  str
end