класс Bundler::Molinillo::DependencyGraph::Vertex
Вершина в {DependencyGraph}, которая инкапсулирует имя {#name} и полезную нагрузку {#payload}
Атрибуты
@return [Массив<Объект>] явные зависимости, которые необходимы
this vertex
@return [Массив<Ребро>] рёбра из {#graph}, у которых `self` является их
{Edge#destination} @return [Строка] имя вершины
@return [Массив<Ребро>] рёбра из {#graph}, у которых `self` является их
{Edge#origin} @return [Объект] полезная нагрузка, которую хранит вершина
@return [Булево] является ли вершина корневой вершиной
@return [Булево] является ли вершина корневой вершиной
Публичные методы класса
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 25 def initialize(name, payload) @name = name.frozen? ? name : name.dup.freeze @payload = payload @explicit_requirements = [] @outgoing_edges = [] @incoming_edges = [] end
Инициализирует вершину с заданным именем и полезной нагрузкой. @param [Строка] name см. {#name} @param [Объект] payload см. {#payload}
Публичные методы экземпляра
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 106
def ==(other)
return true if equal?(other)
shallow_eql?(other) &&
successors.to_set == other.successors.to_set
end @return [Булево] равны ли две вершины, определяется
by a recursive traversal of each {Vertex#successors} # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 151 def ancestor?(other) other.path_to?(self) end
Существует ли путь от `other` к `self` по рёбрам в графе зависимостей? @return true, если существует путь по рёбрам в этом {#graph}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 125 def hash name.hash end
@return [Целое] хэш-значение для вершины, основанное на её {#name}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 100
def inspect
"#{self.class}:#{name}(#{payload.inspect})"
end @return [Строка] строка, подходящая для отладки
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 132 def path_to?(other) _path_to?(other) end
Существует ли путь от `self` к `other` по рёбрам в графе зависимостей? @return true, если существует путь по рёбрам в этом {#graph}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 49 def predecessors incoming_edges.map(&:origin) end
@return [Массив<Вершина>] вершины из {#graph}, у которых есть ребро с
`self` as their {Edge#destination} # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 55 def recursive_predecessors _recursive_predecessors end
@return [Множество<Вершина>] вершины из {#graph}, где `self` является
{#descendent?} # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 81 def recursive_successors _recursive_successors end
@return [Множество<Вершина>] вершины из {#graph}, где `self` является
{#ancestor?} # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 35 def requirements (incoming_edges.map(&:requirement) + explicit_requirements).uniq end
@return [Массив<Объект>] все зависимости, которые требуются
this vertex
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 115
def shallow_eql?(other)
return true if equal?(other)
other &&
name == other.name &&
payload == other.payload
end @param [Вершина] other другая вершина для сравнения @return [Булево] равны ли две вершины, определяется
solely by {#name} and {#payload} equality # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 75 def successors outgoing_edges.map(&:destination) end
@return [Массив<Вершина>] вершины из {#graph}, у которых есть ребро с
`self` as their {Edge#origin} Защищённые методы экземпляра
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 141
def _path_to?(other, visited = Set.new)
return false unless visited.add?(self)
return true if equal?(other)
successors.any? { |v| v._path_to?(other, visited) }
end @param [Вершина] other вершина, для которой проверяется путь @param [Множество<Вершина>] visited вершины из {#graph}, которые были посещены @return [Булево] существует ли путь к `other` из `self`
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 62
def _recursive_predecessors(vertices = Set.new)
incoming_edges.each do |edge|
vertex = edge.origin
next unless vertices.add?(vertex)
vertex._recursive_predecessors(vertices)
end
vertices
end @param [Множество<Вершина>] vertices множество, в которое добавляются предшественники @return [Множество<Вершина>] вершины из {#graph}, где `self` является
{#descendent?} # File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb, line 88
def _recursive_successors(vertices = Set.new)
outgoing_edges.each do |edge|
vertex = edge.destination
next unless vertices.add?(vertex)
vertex._recursive_successors(vertices)
end
vertices
end @param [Множество<Вершина>] vertices множество, в которое добавляются преемники @return [Множество<Вершина>] вершины из {#graph}, где `self` является
{#ancestor?}
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.