KScript docs
EN

slash_path fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

Fields

FieldTypeDescription
.depthnumberHow many names it has: 2 for /My Apps/Notes, 0 for /.
.is_rootboolTrue for / itself.
.namestringThe last name: Notes in /My Apps/Notes, or '' for /.
.parentslash_pathThe path one up: /My Apps for /My Apps/Notes, / for /My Apps, and null for /.
.segmentslistThe names in order: ['My Apps', 'Notes'] for /My Apps/Notes.

From KScript.Core

#slash_path->is_within(other: slash_path) → bool

True when it is the other path or under it: /docs/guides/start is within /docs. Names are compared exactly, case included.
ParameterTakes
other requiredslash_path
Example
<let name="x" type="slash_path" value="'/My Apps/Notes/Today'" />
<echo>{ $x->is_within('/My Apps') }</echo>
$x: slash_path = '/My Apps/Notes/Today'
echo $x->is_within('/My Apps')

#slash_path->join(more: string) → slash_path

The path with more names added on the end and tidied: /docs joined with 'guides/../start' is /docs/start. A / at the start of more is ignored.
ParameterTakes
more requiredstring
Example
<let name="x" type="slash_path" value="'/My Apps/Notes/Today'" />
<echo>{ $x->join('../Tomorrow') }</echo>
$x: slash_path = '/My Apps/Notes/Today'
echo $x->join('../Tomorrow')

Methods from any

Methods from string