struct Bindgen::Graph::Path
- Bindgen::Graph::Path
- Struct
- Value
- Object
Overview
Pathing logic for the graph. See Path.local
to find a locally-qualified
path between two nodes. Or use .from
to build a path from a string.
The structure doesn't store any origin by itself.
Defined in:
bindgen/graph/path.crConstructors
-
.from(path : String) : Path
Returns a new
Path
on path. -
.from(path : Path) : Path
Returns a new
Path
on path. -
.from(paths : Enumerable(String | Path)) : Path
Returns a new
Path
formed by concatenating the given paths. -
.from(first_path : String | Path, *remaining : String | Path) : Path
Returns a new
Path
formed by concatenating the given paths. -
.global(node : Node) : Path
Returns the global path to node.
-
.global_root : Path
Returns a path that refers to the global root.
-
.local(from node : Node, to wants : Node) : Path
Finds the local path to go from node to wants, in terms of constant resolution for Crystal.
-
.self_path : Path
Returns a self-referencing path.
Instance Method Summary
- #==(other : self)
-
#[](range : Range) : Path
Returns the
Path
with the parts in range. -
#empty?(*args, **options)
Is this an empty path?
-
#empty?(*args, **options, &)
Is this an empty path?
-
#global? : Bool
Is this a global path?
-
#hash(hasher)
See
Object#hash(hasher)
-
#inspect(io)
Much like
#to_s
, but tells the user when this path points to itself. -
#join(other : Path) : Path
Combines the other path into this path.
- #last : Path
-
#last_part : String
Returns the last part of this path.
-
#local?
Is this a local path? Also
true
if this is a#self_path?
path. -
#lookup(base : Node) : Node | Nil
Does a local look-up starting at base for path.
-
#parent : Path
Returns the
Path
excluding the last part in#nodes
, thus pointing to the parent of this path. -
#parts : Array(String)
The names of the path at each namespace.
-
#self_path?
Does this path point to itself?
-
#to_global(base : Node) : Path
Returns a global path from this local path, starting look-up at base.
-
#to_s(io)
Gives the path as Crystal constants look-up path.
Constructor Detail
Returns a new Path
on path. Supports generic parts.
Returns a new Path
on path. Supports generic parts.
Returns a new Path
formed by concatenating the given paths. An empty
collection produces a self-path.
Returns a new Path
formed by concatenating the given paths. An empty
collection produces a self-path.
Finds the local path to go from node to wants, in terms of constant resolution for Crystal.
Each call may perform multiple look-ups to ensure the resulting local path refers to wants unambiguously. If this cannot be done, a global path will be returned.
Instance Method Detail
Returns the Path
with the parts in range. The new Path
is global
only if it includes the first part of this Path
and this Path
is
also global.
Combines the other path into this path. If the other path is global, simply returns other. Otherwise, the new path contains the parts from this path, followed by the parts from other.
Returns the local Path
with only the last part in #nodes
, thus
pointing at the child in #parent
. Raises if this is an empty path.
Does a local look-up starting at base for path. The look-up will begin in base itself. If not found, it'll try to find the path by going up to the parent(s).
If the path starts with ::
(An empty element), the look-up will
always start at the global scope. If path is exactly ::
, the root
node (not the global root) is returned. Otherwise, the first part of
the path must be the name of the root node: ::RootName::And::So::On
instead of ::And::So::On
.
If not found, returns nil
. This method does not raise.
Returns the Path
excluding the last part in #nodes
, thus pointing
to the parent of this path. Returns a global path if this path is also
global. Raises if this is an empty path.
Returns a global path from this local path, starting look-up at base. Does a full look-up under the hood, thus, the path has to be valid.
If this is already a #global?
path, it is returned without further
checks.