Class: Linux::Ip::Addr::IpAddr
- Inherits:
-
Object
- Object
- Linux::Ip::Addr::IpAddr
- Defined in:
- lib/linux/ip/addr.rb
Instance Attribute Summary collapse
-
#interfaces ⇒ Object
readonly
Returns the value of attribute interfaces.
Instance Method Summary collapse
- #as_commands(direction = "add") ⇒ Object
- #execute_add ⇒ Object
- #execute_del ⇒ Object
- #find(name) ⇒ Object
-
#initialize ⇒ IpAddr
constructor
A new instance of IpAddr.
- #length ⇒ Object
Constructor Details
#initialize ⇒ IpAddr
Returns a new instance of IpAddr.
28 29 30 |
# File 'lib/linux/ip/addr.rb', line 28 def initialize @interfaces = [] end |
Instance Attribute Details
#interfaces ⇒ Object (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_add ⇒ Object
42 43 44 |
# File 'lib/linux/ip/addr.rb', line 42 def execute_add system as_commands("add") end |
#execute_del ⇒ Object
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 |
#length ⇒ Object
31 32 33 |
# File 'lib/linux/ip/addr.rb', line 31 def length interfaces.length end |