Class: HttpRouter::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/http_router/node.rb,
lib/http_router/node/glob.rb,
lib/http_router/node/root.rb,
lib/http_router/node/regex.rb,
lib/http_router/node/lookup.rb,
lib/http_router/node/request.rb,
lib/http_router/node/variable.rb,
lib/http_router/node/arbitrary.rb,
lib/http_router/node/free_regex.rb,
lib/http_router/node/glob_regex.rb,
lib/http_router/node/destination.rb,
lib/http_router/node/spanning_regex.rb

Direct Known Subclasses

Arbitrary, Destination, FreeRegex, Glob, Lookup, Regex, Request, Root, Variable

Defined Under Namespace

Classes: Arbitrary, Destination, FreeRegex, Glob, GlobRegex, Lookup, Regex, Request, Root, SpanningRegex, Variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(router, parent, matchers = []) ⇒ Node

Returns a new instance of Node.



18
19
20
# File 'lib/http_router/node.rb', line 18

def initialize(router, parent, matchers = [])
  @router, @parent, @matchers = router, parent, matchers
end

Instance Attribute Details

#node_positionObject (readonly)

Returns the value of attribute node_position.



16
17
18
# File 'lib/http_router/node.rb', line 16

def node_position
  @node_position
end

#parentObject (readonly)

Returns the value of attribute parent.



16
17
18
# File 'lib/http_router/node.rb', line 16

def parent
  @parent
end

#priorityObject (readonly)

Returns the value of attribute priority.



16
17
18
# File 'lib/http_router/node.rb', line 16

def priority
  @priority
end

#routerObject (readonly)

Returns the value of attribute router.



16
17
18
# File 'lib/http_router/node.rb', line 16

def router
  @router
end

Instance Method Details

#add_arbitrary(blk, allow_partial, param_names) ⇒ Object



38
39
40
# File 'lib/http_router/node.rb', line 38

def add_arbitrary(blk, allow_partial, param_names)
  add(Arbitrary.new(@router, self, allow_partial, blk, param_names))
end

#add_destination(blk, partial) ⇒ Object



54
55
56
# File 'lib/http_router/node.rb', line 54

def add_destination(blk, partial)
  add(Destination.new(@router, self, blk, partial))
end

#add_free_match(regexp) ⇒ Object



50
51
52
# File 'lib/http_router/node.rb', line 50

def add_free_match(regexp)
  add(FreeRegex.new(@router, self, regexp))
end

#add_globObject



26
27
28
# File 'lib/http_router/node.rb', line 26

def add_glob
  add(Glob.new(@router, self))
end

#add_glob_regexp(matcher) ⇒ Object



30
31
32
# File 'lib/http_router/node.rb', line 30

def add_glob_regexp(matcher)
  add(GlobRegex.new(@router, self, matcher))
end

#add_lookup(part) ⇒ Object



58
59
60
# File 'lib/http_router/node.rb', line 58

def add_lookup(part)
  add(Lookup.new(@router, self)).add(part)
end

#add_match(regexp, matching_indicies = [0], splitting_indicies = nil) ⇒ Object



42
43
44
# File 'lib/http_router/node.rb', line 42

def add_match(regexp, matching_indicies = [0], splitting_indicies = nil)
  add(Regex.new(@router, self, regexp, matching_indicies, splitting_indicies))
end

#add_request(opts) ⇒ Object



34
35
36
# File 'lib/http_router/node.rb', line 34

def add_request(opts)
  add(Request.new(@router, self, opts))
end

#add_spanning_match(regexp, matching_indicies = [0], splitting_indicies = nil) ⇒ Object



46
47
48
# File 'lib/http_router/node.rb', line 46

def add_spanning_match(regexp, matching_indicies = [0], splitting_indicies = nil)
  add(SpanningRegex.new(@router, self, regexp, matching_indicies, splitting_indicies))
end

#add_variableObject



22
23
24
# File 'lib/http_router/node.rb', line 22

def add_variable
  add(Variable.new(@router, self))
end

#usable?(other) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/http_router/node.rb', line 62

def usable?(other)
  false
end