class Amber::Router::RouteSet(T)

Defined in:

route_set.cr

Constant Summary

FIXED = 2
GLOB = 8
ROOT = 1
VARIABLE = 4

Constructors

Instance Method Summary

Constructor Detail

def self.new(segment : String = "#", trunk : Nil | Amber::Router::RouteSet(T) = nil) #

A tree data structure (recursive). The initial construction has an segment of "root" and no trunk. Subtrees must pass in these details upon creation.


[View source]

Instance Method Detail

def add(path, route : T) : Nil #

Add a route to the tree.


[View source]
def deep_clone : RouteSet(T) #

[View source]
def find(path) : RoutedResult #

Find a route which has been assigned to a matching path Weakness: assumes only one route will match the path query.


[View source]
def find_subtree(segment : String) : RouteSet(T) | Nil #

Look for and return a subtree matching a given segment.


[View source]
def find_subtree!(segment : String) : RouteSet(T) #

Look for or create a subtree matching a given segment.


[View source]
def fixed? : Bool #

[View source]
def full_path : String | Nil #

[View source]
def full_path=(full_path : String | Nil) #

[View source]
def glob? : Bool #

[View source]
def inspect(*, ts = 0) #

Produces a readable indented rendering of the tree, though not really compatible with the other components of a deep object inspection


[View source]
def leaf? : Bool #

[View source]
def reverse_select_routes!(path : Array(String)) : Tuple(Bool, Array(String)) #

Recursively matches the right hand side of a glob segment. Allows for routes like /a/b//d/e and /a/b//f/g to coexist. This is a modified version of a destructive depth first search.

Importantly, each subtree must pass back up the remaining part of the path so it can be matched against the parent, so this method somewhat awkwardly returns:

Tuple(subtree_match : Bool, path_for_trunk_to_match : String)


[View source]
def root? : Bool #

[View source]
def routable? : Bool #

[View source]
def route #

Recursively descend to find the attached application route. Weakness: assumes only one path remains in the tree.


[View source]
def routes? : Bool #

[View source]
def segment : String #

[View source]
def segment=(segment : String) #

[View source]
def segment_match?(segment : String) : Bool #

[View source]
def segment_type #

[View source]
def segment_type=(segment_type : Int32) #

[View source]
def select_routes!(path : Array(String) | Nil) : Bool #

Recursively prunes the route tree by matching segments against path segment strings.

A destructive breadth first search.

return true if any routes matched.


[View source]
def size #

Recursively count the number of discrete paths remaining in the tree.


[View source]
def variable? : Bool #

[View source]