Sha256: a1be72366b43e4a2d83559e18bd4de07b8be03c1de984b79595d61523b31554e
Contents?: true
Size: 683 Bytes
Versions: 7
Compression:
Stored size: 683 Bytes
Contents
module RGL class PathBuilder def initialize(source, parents_map) @source = source @parents_map = parents_map @paths = {} end def path(target) if @paths.has_key?(target) @paths[target] else @paths[target] = restore_path(target) end end # @return [Hash] def paths(targets) paths_map = {} targets.each do |target| paths_map[target] = path(target) end paths_map end private def restore_path(target) return [@source] if target == @source parent = @parents_map[target] path(parent) + [target] if parent end end end # RGL
Version data entries
7 entries across 7 versions & 1 rubygems