struct

Bindgen::Graph::Path

Inherits Struct < Value < Object

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.

Constructors

from(path : String, *, generic : Bool = false) : Path

Returns a new Path on path. All generic type arguments are removed, unless generic is true.

Source
from(path : Path, *, generic : Bool = false) : Path

Returns a new Path on path. All generic type arguments are removed, unless generic is true.

Source
from(paths : Enumerable(String | Path), *, generic : Bool = false) : Path

Returns a new Path formed by concatenating the given paths. Each path in the collection may correspond to more than one namespace level; an empty collection produces a self-path.

Source
from(first_path : String | Path, *remaining : String | Path, generic : Bool = false) : Path

Returns a new Path formed by concatenating the given paths. Each path in the collection may correspond to more than one namespace level; an empty collection produces a self-path.

Source
global(node : Node) : Path

Returns the global path to node.

Source
global_root

Returns a path that refers to the global root.

Source
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.

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.

Source
self_path

Returns a self-referencing path.

Source

Instance methods

==(other : self)
[](range : Range) : Path

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.

Source
camelcase

Returns a copy of this path with every part CamelCased.

Source
empty?(*args, **options)

Is this an empty path?

Source
empty?(*args, **options, &)

Is this an empty path?

Source
global?

Is this a global path?

Source
hash(hasher)

See Object#hash(hasher)

inspect(io)

Much like #to_s, but tells the user when this path points to itself.

Source
join(other : Path) : Path

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.

Source
last

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.

Source
last_part

Returns the last part of this path. Raises if this is an empty path.

Source
local?

Is this a local path? Also true if this is a #self_path? path.

Source
lookup(base : Node) : Node | Nil

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.

Source
parent

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.

Source
parts

The names of the path at each namespace.

Source
self_path?

Does this path point to itself?

Source
to_global(base : Node) : 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.

Source
to_s(io)

Gives the path as Crystal constants look-up path.

Source