class HttpRouter::Node
Attributes
router[R]
Public Class Methods
new(router, parent, matchers = [])
click to toggle source
# File lib/http_router/node.rb, line 21 def initialize(router, parent, matchers = []) @router, @parent, @matchers = router, parent, matchers end
Public Instance Methods
add_destination(route, path, param_names = [])
click to toggle source
# File lib/http_router/node.rb, line 65 def add_destination(route, path, param_names = []) add(Path.new(@router, self, route, path, param_names)) end
add_free_match(regexp)
click to toggle source
# File lib/http_router/node.rb, line 61 def add_free_match(regexp) add(FreeRegex.new(@router, self, regexp)) end
add_glob()
click to toggle source
# File lib/http_router/node.rb, line 29 def add_glob add(Glob.new(@router, self)) end
add_glob_regexp(matcher)
click to toggle source
# File lib/http_router/node.rb, line 33 def add_glob_regexp(matcher) add(GlobRegex.new(@router, self, matcher)) end
add_host(hosts)
click to toggle source
# File lib/http_router/node.rb, line 37 def add_host(hosts) add(Host.new(@router, self, hosts)) end
add_lookup(part)
click to toggle source
# File lib/http_router/node.rb, line 69 def add_lookup(part) add(Lookup.new(@router, self)).add(part) end
add_match(regexp, matching_indicies = [0], splitting_indicies = nil)
click to toggle source
# File lib/http_router/node.rb, line 53 def add_match(regexp, matching_indicies = [0], splitting_indicies = nil) add(Regex.new(@router, self, regexp, matching_indicies, splitting_indicies)) end
add_request_method(rm)
click to toggle source
# File lib/http_router/node.rb, line 45 def add_request_method(rm) add(RequestMethod.new(@router, self, rm)) end
add_scheme(scheme)
click to toggle source
# File lib/http_router/node.rb, line 49 def add_scheme(scheme) add(Scheme.new(@router, self, scheme)) end
add_spanning_match(regexp, matching_indicies = [0], splitting_indicies = nil)
click to toggle source
# File lib/http_router/node.rb, line 57 def add_spanning_match(regexp, matching_indicies = [0], splitting_indicies = nil) add(SpanningRegex.new(@router, self, regexp, matching_indicies, splitting_indicies)) end
add_user_agent(uas)
click to toggle source
# File lib/http_router/node.rb, line 41 def add_user_agent(uas) add(UserAgent.new(@router, self, uas)) end
add_variable()
click to toggle source
# File lib/http_router/node.rb, line 25 def add_variable add(Variable.new(@router, self)) end
depth()
click to toggle source
# File lib/http_router/node.rb, line 94 def depth @parent.send(:depth) + 1 end
inspect()
click to toggle source
# File lib/http_router/node.rb, line 77 def inspect ins = "#{' ' * depth}#{inspect_label}" body = inspect_matchers_body unless body =~ /^\s*$/ ins << "\n" << body end ins end
inspect_label()
click to toggle source
# File lib/http_router/node.rb, line 86 def inspect_label "#{self.class.name.split("::").last} (#{@matchers.size} matchers)" end
inspect_matchers_body()
click to toggle source
# File lib/http_router/node.rb, line 90 def inspect_matchers_body @matchers.map{ |m| m.inspect}.join("\n") end
usable?(other)
click to toggle source
# File lib/http_router/node.rb, line 73 def usable?(other) false end
Private Instance Methods
add(matcher)
click to toggle source
# File lib/http_router/node.rb, line 107 def add(matcher) @matchers << matcher unless matcher.usable?(@matchers.last) @matchers.last end
inject_root_ivar(obj)
click to toggle source
# File lib/http_router/node.rb, line 103 def inject_root_ivar(obj) root.inject_root_ivar(obj) end
inject_root_methods(code = nil, &blk)
click to toggle source
# File lib/http_router/node.rb, line 99 def inject_root_methods(code = nil, &blk) code ? root.methods_module.module_eval(code) : root.methods_module.module_eval(&blk) end
root()
click to toggle source
# File lib/http_router/node.rb, line 116 def root @router.root end
to_code()
click to toggle source
# File lib/http_router/node.rb, line 112 def to_code @matchers.map{ |m| "# #{m.class}\n" << m.to_code }.join("\n") << "\n" end
use_named_captures?()
click to toggle source
# File lib/http_router/node.rb, line 120 def use_named_captures? //.respond_to?(:names) end