Class: Linux::Ip::Addr::IpAddr

Inherits:
Object
  • Object
show all
Defined in:
lib/linux/ip/addr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIpAddr

Returns a new instance of IpAddr.



28
29
30
# File 'lib/linux/ip/addr.rb', line 28

def initialize
  @interfaces = []
end

Instance Attribute Details

#interfacesObject (readonly)

Returns the value of attribute interfaces.



27
28
29
# File 'lib/linux/ip/addr.rb', line 27

def interfaces
  @interfaces
end

Instance Method Details

#as_commands(direction = "add") ⇒ Object



37
38
39
40
41
# File 'lib/linux/ip/addr.rb', line 37

def as_commands(direction="add")
  @interfaces.map do |interface|
    interface.as_commands(direction)
  end.flatten.compact
end

#execute_addObject



42
43
44
# File 'lib/linux/ip/addr.rb', line 42

def execute_add
  system as_commands("add")
end

#execute_delObject



45
46
47
# File 'lib/linux/ip/addr.rb', line 45

def execute_del
  system as_commands("del")
end

#find(name) ⇒ Object



34
35
36
# File 'lib/linux/ip/addr.rb', line 34

def find(name)
  interfaces.find { |i| i.name == name }
end

#lengthObject



31
32
33
# File 'lib/linux/ip/addr.rb', line 31

def length
  interfaces.length
end