Class: HttpRouter::Node::FreeRegex

### Home Classes Methods

### In Files

- lib/http_router/node/free_regex.rb

### Parent

HttpRouter::Node

### Methods

- ::new
- #to_code
- #usable?

### Files

- LICENSE

### Class/Module Index

Quicksearch

- HttpRouter
- HttpRouter::GenerationHelper
- HttpRouter::Generator
- HttpRouter::Generator::PathGenerator
- HttpRouter::Node
- HttpRouter::Node::AbstractRequestNode
- HttpRouter::Node::FreeRegex
- HttpRouter::Node::Glob
- HttpRouter::Node::GlobRegex
- HttpRouter::Node::Host
- HttpRouter::Node::Lookup
- HttpRouter::Node::Path
- HttpRouter::Node::Regex
- HttpRouter::Node::RequestMethod
- HttpRouter::Node::Root
- HttpRouter::Node::Scheme
- HttpRouter::Node::SpanningRegex
- HttpRouter::Node::UserAgent
- HttpRouter::Node::Variable
- HttpRouter::RegexRouteGeneration
- HttpRouter::Request
- HttpRouter::Response
- HttpRouter::Route
- HttpRouter::RouteHelper
- HttpRouter::Util

No matching classes.

# HttpRouter::Node::FreeRegex

### Attributes

matcher[R]

### Public Class Methods

new(router, parent, matcher) click to toggle source

    # File lib/http_router/node/free_regex.rb, line 5
    def initialize(router, parent, matcher)
      @matcher = matcher
      super(router, parent)
    end

### Public Instance Methods

to_code() click to toggle source

    # File lib/http_router/node/free_regex.rb, line 10
    def to_code
      id = root.next_counter
      "whole_path#{id} = \"/\#{request.joined_path}\"
      if match = #{matcher.inspect}.match(whole_path#{id}) and match[0].size == whole_path#{id}.size
        request.extra_env['router.regex_match'] = match
        old_path = request.path
        request.path = ['']
        " << (use_named_captures? ?
        "match.names.size.times{|i| request.params << match[i + 1]} if match.respond_to?(:names) && match.names" : "") << "
        #{super}
        request.path = old_path
        request.extra_env.delete('router.regex_match')
        " << (use_named_captures? ?
        "params.slice!(-match.names.size, match.names.size)" : ""
        ) << "
      end"
    end

usable?(other) click to toggle source

    # File lib/http_router/node/free_regex.rb, line 28
    def usable?(other)
      other.class == self.class && other.matcher == matcher
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.