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 Field Type Description .depthnumber How many names it has: 2 for /My Apps/Notes, 0 for /. .is_rootbool True for / itself. .namestring The last name: Notes in /My Apps/Notes, or '' for /. .parentslash_path The path one up: /My Apps for /My Apps/Notes, / for /My Apps, and null for /. .segmentslist The 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.
Example
.kscript XML Copy
<let name="x" type="slash_path" value="'/My Apps/Notes/Today'" />
<echo>{ $x->is_within('/My Apps') }</echo>.kscript XML Copy
$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.
Parameter Takes more required string
Example
.kscript XML Copy
<let name="x" type="slash_path" value="'/My Apps/Notes/Today'" />
<echo>{ $x->join('../Tomorrow') }</echo>.kscript XML Copy
$x: slash_path = '/My Apps/Notes/Today'
echo $x->join('../Tomorrow')Methods from any Methods from string ->contains(text, ignore_case?: bool)->count()->ends_with(text, ignore_case?: bool)->escape()->index_of(text, ignore_case?: bool, last?: bool)->lower()->markdown_escape()->matches(pattern: regex)->pad(width: number, char?, start?: bool)->replace(old, new, ignore_case?: bool)->slice(start: number, end?: number)->split(separator?)->starts_with(text, ignore_case?: bool)->truncate(length: number, suffix?)->upper()->url_encode()