class Amber::Router::RouteSet(T)
- Amber::Router::RouteSet(T)
- Reference
- Object
Defined in:
route_set.crConstant Summary
-
FIXED =
2
-
GLOB =
8
-
ROOT =
1
-
VARIABLE =
4
Constructors
-
.new(segment : String = "#", trunk : Nil | Amber::Router::RouteSet(T) = nil)
A tree data structure (recursive).
Instance Method Summary
-
#add(path, route : T) : Nil
Add a route to the tree.
- #deep_clone : RouteSet(T)
-
#find(path) : RoutedResult
Find a route which has been assigned to a matching path Weakness: assumes only one route will match the path query.
-
#find_subtree(segment : String) : RouteSet(T) | Nil
Look for and return a subtree matching a given segment.
-
#find_subtree!(segment : String) : RouteSet(T)
Look for or create a subtree matching a given segment.
- #fixed? : Bool
- #full_path : String | Nil
- #full_path=(full_path : String | Nil)
- #glob? : Bool
-
#inspect(*, ts = 0)
Produces a readable indented rendering of the tree, though not really compatible with the other components of a deep object inspection
- #leaf? : Bool
-
#reverse_select_routes!(path : Array(String)) : Tuple(Bool, Array(String))
Recursively matches the right hand side of a glob segment.
- #root? : Bool
- #routable? : Bool
-
#route
Recursively descend to find the attached application route.
- #routes? : Bool
- #segment : String
- #segment=(segment : String)
- #segment_match?(segment : String) : Bool
- #segment_type
- #segment_type=(segment_type : Int32)
-
#select_routes!(path : Array(String) | Nil) : Bool
Recursively prunes the route tree by matching segments against path segment strings.
-
#size
Recursively count the number of discrete paths remaining in the tree.
- #variable? : Bool
Constructor Detail
A tree data structure (recursive). The initial construction has an segment of "root" and no trunk. Subtrees must pass in these details upon creation.
Instance Method Detail
Find a route which has been assigned to a matching path Weakness: assumes only one route will match the path query.
Look for and return a subtree matching a given segment.
Look for or create a subtree matching a given segment.
Produces a readable indented rendering of the tree, though not really compatible with the other components of a deep object inspection
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)
Recursively descend to find the attached application route. Weakness: assumes only one path remains in the tree.
Recursively prunes the route tree by matching segments against path segment strings.
A destructive breadth first search.
return true if any routes matched.