Class: Snails::AppPath

Inherits:
Object show all
Defined in:
runtime/snails/root_path.rb,
runtime/snails/root_path.rbs

Overview

A path value returned by Snails.root.

It is not a String subclass, so the runtime stays statically resolvable. The surface is what app code needs from a path: interpolation, join, +, and the implicit conversion File methods use.

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ AppPath

Returns a new instance of AppPath.

Parameters:



7
# File 'runtime/snails/root_path.rbs', line 7

def initialize: (String base) -> void

Instance Method Details

#+(part) ⇒ AppPath

a path join, not string concatenation.

Parameters:

  • part (String) —

    the part to append

Returns:



49
# File 'runtime/snails/root_path.rb', line 49

def +: (String part) -> AppPath

#join(*parts) ⇒ AppPath

appends path parts with one separator between each.

With no parts it answers this path unchanged, so Snails.root.join is Snails.root.

Examples:

Snails.root.join("tmp", "storage").to_s # => "./tmp/storage"

Parameters:

Returns:



37
# File 'runtime/snails/root_path.rb', line 37

def join: (*String parts) -> AppPath

#to_path ⇒ String

the implicit conversion File methods look for.

It is to_path, not to_str: a path value does not pose as a String.

Returns:



65
# File 'runtime/snails/root_path.rb', line 65

def to_path: () -> String

#to_s ⇒ String

the accumulated path, which is what interpolation prints.

Returns:



56
# File 'runtime/snails/root_path.rb', line 56

def to_s: () -> String