Class: Linux::Ip::Addr::Interface

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Interface

Returns a new instance of Interface.



10
11
12
13
# File 'lib/linux/ip/addr.rb', line 10

def initialize(name)
  @name = name
  @ips = []
end

Instance Attribute Details

#ipsObject (readonly)

Returns the value of attribute ips.



9
10
11
# File 'lib/linux/ip/addr.rb', line 9

def ips
  @ips
end

#mac_addressObject

Returns the value of attribute mac_address.



8
9
10
# File 'lib/linux/ip/addr.rb', line 8

def mac_address
  @mac_address
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/linux/ip/addr.rb', line 9

def name
  @name
end

Instance Method Details

#add_ip(ip) ⇒ Object



14
15
16
17
# File 'lib/linux/ip/addr.rb', line 14

def add_ip(ip)
  @ips << ip
  self
end

#as_commands(direction) ⇒ Object



18
19
20
21
22
# File 'lib/linux/ip/addr.rb', line 18

def as_commands(direction)
  @ips.map do |ip|
    "ip addr #{direction} #{ip} dev #{name}"
  end
end