module

YandexDisk::RemotePath

Helpers for the namespaced paths the REST API speaks.

The API accepts both /photo.png and disk:/photo.png, but it always answers with the prefixed form. Normalising on the way in keeps comparisons between what you asked for and what came back honest.

Trash lives in its own namespace: a file at disk:/a/b.txt becomes trash:/b.txt once deleted, so the two prefixes must not be mixed up.

Constants

KNOWN_PREFIXES = {PREFIX, TRASH_PREFIX}
PREFIX = "disk:"
TRASH_PREFIX = "trash:"

Class methods

ancestors(path : String) : Array(String)

Every ancestor of path from the shallowest down, excluding the root.

ancestors("disk:/a/b/c") => ["disk:/a", "disk:/a/b", "disk:/a/b/c"]

Source
basename(path : String) : String
Source
dirname(path : String) : String | Nil

Returns the parent of path, or nil when path is the root.

Source
join(*parts : String) : String
Source
normalize(path : String, prefix : String = PREFIX) : String

Returns path under prefix, collapsing repeated and trailing slashes.

An existing namespace prefix is replaced, so normalize("trash:/a") yields disk:/a unless you ask for the trash namespace explicitly.

Source
trash(path : String) : String

normalize into the Trash namespace.

Source