class Tinet::Switch

Attributes

interfaces[R]
name[R]

Public Class Methods

new(name, interfaces) click to toggle source

@param name [String] @param interfaces [Array<Tinet::Switch::Interfase>]

# File lib/tinet/switch.rb, line 18
def initialize(name, interfaces)
  @name = name
  @interfaces = interfaces
  interfaces.each { |interface| interface.switch = self }
end
parse(switch_hash) click to toggle source

@param switch_hash [Hash] @return [Tinet::Switch]

# 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