Class: Tinet::Node::Interfase
- Inherits:
-
Object
- Object
- Tinet::Node::Interfase
- Defined in:
- lib/tinet/node.rb
Constant Summary collapse
- TYPES =
%w(direct bridge veth phys).freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, type, args) ⇒ Interfase
constructor
A new instance of Interfase.
Constructor Details
#initialize(name, type, args) ⇒ Interfase
Returns a new instance of Interfase.
53 54 55 56 57 58 |
# File 'lib/tinet/node.rb', line 53 def initialize(name, type, args) @name = name @type = type.to_sym @args = args @node = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
48 49 50 |
# File 'lib/tinet/node.rb', line 48 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'lib/tinet/node.rb', line 48 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
48 49 50 |
# File 'lib/tinet/node.rb', line 48 def node @node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
48 49 50 |
# File 'lib/tinet/node.rb', line 48 def type @type end |
Class Method Details
.parse(interface_hash) ⇒ Tinet::Node::Interfase
41 42 43 44 45 46 |
# File 'lib/tinet/node.rb', line 41 def self.parse(interface_hash) name, type, args = interface_hash['name'], interface_hash['type'], interface_hash['args'] raise InvalidYAMLError, "Interfase name is missing" if name.nil? || name.empty? raise InvalidTypeError, "Unknown interface type: #{type}" unless TYPES.include?(type) self.new(name, type.to_sym, args) end |