Class: Gin::Router::Node
- Inherits:
-
Object
- Object
- Gin::Router::Node
- Defined in:
- lib/gin/router.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add_child(key) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #match(key) ⇒ Object
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
212 213 214 |
# File 'lib/gin/router.rb', line 212 def initialize @children = {} end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
210 211 212 |
# File 'lib/gin/router.rb', line 210 def value @value end |
Instance Method Details
#[](key) ⇒ Object
216 217 218 |
# File 'lib/gin/router.rb', line 216 def [] key @children[key] end |
#add_child(key) ⇒ Object
229 230 231 |
# File 'lib/gin/router.rb', line 229 def add_child key @children[key] ||= Node.new end |
#match(key) ⇒ Object
220 221 222 223 224 225 226 227 |
# File 'lib/gin/router.rb', line 220 def match key @children.keys.each do |k| next unless Regexp === k m = k.match key return [@children[k], m[1..-1]] if m end nil end |