Class: Tinet::Switch
- Inherits:
-
Object
- Object
- Tinet::Switch
- Defined in:
- lib/tinet/switch.rb
Defined Under Namespace
Classes: Interfase
Instance Attribute Summary collapse
-
#interfaces ⇒ Object
readonly
Returns the value of attribute interfaces.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, interfaces) ⇒ Switch
constructor
A new instance of Switch.
Constructor Details
#initialize(name, interfaces) ⇒ Switch
Returns a new instance of Switch.
18 19 20 21 22 |
# File 'lib/tinet/switch.rb', line 18 def initialize(name, interfaces) @name = name @interfaces = interfaces interfaces.each { |interface| interface.switch = self } end |
Instance Attribute Details
#interfaces ⇒ Object (readonly)
Returns the value of attribute interfaces.
14 15 16 |
# File 'lib/tinet/switch.rb', line 14 def interfaces @interfaces end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/tinet/switch.rb', line 14 def name @name end |
Class Method Details
.parse(switch_hash) ⇒ Tinet::Switch
5 6 7 8 9 10 11 12 |
# File 'lib/tinet/switch.rb', line 5 def self.parse(switch_hash) name, interfaces = switch_hash['name'], switch_hash['interfaces'] raise InvalidYAMLError, "Switch name is missing" if name.nil? || name.empty? raise InvalidYAMLError, "Switch interfaces must be array" unless interfaces.is_a?(Array) interfaces = interfaces.map { |interface| Interfase.parse(interface) } self.new(name, interfaces) end |