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.
266 267 268 |
# File 'lib/gin/router.rb', line 266 def initialize @children = {} end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
264 265 266 |
# File 'lib/gin/router.rb', line 264 def value @value end |
Instance Method Details
#[](key) ⇒ Object
270 271 272 |
# File 'lib/gin/router.rb', line 270 def [] key @children[key] end |
#add_child(key) ⇒ Object
283 284 285 |
# File 'lib/gin/router.rb', line 283 def add_child key @children[key] ||= Node.new end |
#match(key) ⇒ Object
274 275 276 277 278 279 280 281 |
# File 'lib/gin/router.rb', line 274 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 |