Class: VpsAdminOS::Converter::NetInterface::Base
- Inherits:
-
Object
- Object
- VpsAdminOS::Converter::NetInterface::Base
- Defined in:
- lib/vpsadminos-converter/net_interface/base.rb
Instance Attribute Summary collapse
-
#hwaddr ⇒ Object
Returns the value of attribute hwaddr.
-
#ip_addresses ⇒ Object
readonly
Returns the value of attribute ip_addresses.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(name, hwaddr = nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(name, hwaddr = nil) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 18 def initialize(name, hwaddr = nil) @name = name @hwaddr = hwaddr @type = self.class.type @ip_addresses = { 4 => [], 6 => [] } end |
Instance Attribute Details
#hwaddr ⇒ Object
Returns the value of attribute hwaddr.
15 16 17 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 15 def hwaddr @hwaddr end |
#ip_addresses ⇒ Object (readonly)
Returns the value of attribute ip_addresses.
16 17 18 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 16 def ip_addresses @ip_addresses end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 15 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 16 def type @type end |
Class Method Details
.type(name = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 5 def self.type(name = nil) if name NetInterface.register(name, self) @type = name else @type end end |
Instance Method Details
#dump ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vpsadminos-converter/net_interface/base.rb', line 25 def dump { 'type' => type.to_s, 'name' => name, 'hwaddr' => hwaddr, 'ip_addresses' => ip_addresses.to_h do |v, ips| ["v#{v}", ips.map(&:to_string)] end } end |