def ensure_output_port(port)
      raise ArgumentError, "port argument cannot be nil" if port.nil?
      unless port.kind_of?(Port)
        port = output_port(port)
        raise ArgumentError, "the given port doesn't exists" if port.nil?
      end
      unless port.host == self
        raise InvalidPortHostError, "The given port doesn't belong to this \
        model"
      end
      unless port.output?
        raise InvalidPortTypeError, "The given port isn't an output port"
      end
      port
    end
def ensure_output_port(port)
      raise ArgumentError, "port argument cannot be nil" if port.nil?
      unless port.kind_of?(Port)
        port = output_port(port)
        raise ArgumentError, "the given port doesn't exists" if port.nil?
      end
      unless port.host == self
        raise InvalidPortHostError, "The given port doesn't belong to this \
        model"
      end
      unless port.output?
        raise InvalidPortTypeError, "The given port isn't an output port"
      end
      port
    end
Finds and checks if the given port is an output port

 @api private
 @param port [Port, String, Symbol] the port or its name
 @return [Port] the matching port
 @raise [NoSuchPortError] if the given port doesn't exists
 @raise [InvalidPortHostError] if the given port doesn't belong to this
   model
 @raise [InvalidPortTypeError] if the given port isn't an output port