Class: Rage::Router::ParentNode
Direct Known Subclasses
Constant Summary
Constants inherited from Node
Node::PARAMETRIC, Node::STATIC, Node::WILDCARD
Instance Attribute Summary collapse
-
#static_children ⇒ Object
readonly
Returns the value of attribute static_children.
Attributes inherited from Node
#handler_storage, #is_leaf_node, #kind
Instance Method Summary collapse
- #create_static_child(path) ⇒ Object
- #find_static_matching_child(path, path_index) ⇒ Object
-
#initialize ⇒ ParentNode
constructor
A new instance of ParentNode.
Methods inherited from Node
Constructor Details
#initialize ⇒ ParentNode
Returns a new instance of ParentNode.
32 33 34 35 |
# File 'lib/rage/router/node.rb', line 32 def initialize super @static_children = {} end |
Instance Attribute Details
#static_children ⇒ Object (readonly)
Returns the value of attribute static_children.
30 31 32 |
# File 'lib/rage/router/node.rb', line 30 def static_children @static_children end |
Instance Method Details
#create_static_child(path) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rage/router/node.rb', line 47 def create_static_child(path) if path.length == 0 return self end static_child = @static_children[path[0]] if static_child i = 1 while i < static_child.prefix.length if path[i] != static_child.prefix[i] static_child = static_child.split(self, i) break end i += 1 end return static_child.create_static_child(path[i, path.length - i]) end @static_children[path[0]] = StaticNode.new(path) end |
#find_static_matching_child(path, path_index) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rage/router/node.rb', line 37 def find_static_matching_child(path, path_index) static_child = @static_children[path[path_index]] if !static_child || !static_child.match_prefix.call(path, path_index) return nil end static_child end |