Class: Gin::Router::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/gin/router.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



266
267
268
# File 'lib/gin/router.rb', line 266

def initialize
  @children = {}
end

Instance Attribute Details

#valueObject

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