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.



212
213
214
# File 'lib/gin/router.rb', line 212

def initialize
  @children = {}
end

Instance Attribute Details

#valueObject

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