Class: Tinet::Switch::Interfase
- Inherits:
-
Object
- Object
- Tinet::Switch::Interfase
- Defined in:
- lib/tinet/switch.rb
Constant Summary collapse
- TYPES =
%w(docker netns phys).freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#switch ⇒ Object
Returns the value of attribute switch.
-
#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.
41 42 43 44 45 46 |
# File 'lib/tinet/switch.rb', line 41 def initialize(name, type, args) @name = name @type = type.to_sym @args = args @switch = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
36 37 38 |
# File 'lib/tinet/switch.rb', line 36 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/tinet/switch.rb', line 36 def name @name end |
#switch ⇒ Object
Returns the value of attribute switch.
36 37 38 |
# File 'lib/tinet/switch.rb', line 36 def switch @switch end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
36 37 38 |
# File 'lib/tinet/switch.rb', line 36 def type @type end |
Class Method Details
.parse(interface_hash) ⇒ Tinet::Switch::Interfase
29 30 31 32 33 34 |
# File 'lib/tinet/switch.rb', line 29 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 |