class Rack::App::Router::Tree::Env

Constants

SPECIAL_PATH_ELEMENTS

Attributes

endpoint[R]
params[R]
request_path_parts[R]

Public Class Methods

new(endpoint) click to toggle source
# File lib/rack/app/router/tree/env.rb, line 42
def initialize(endpoint)
  @index = 0
  @params = {}
  @endpoint = endpoint
  @request_path_parts = request_path_parts_by(endpoint).freeze
end

Public Instance Methods

branch?() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 10
def branch?
  !clean_request_path_parts[@index..-2].empty?
end
current() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 6
def current
  @request_path_parts[@index]
end
next() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 34
def next
  env = self.dup
  env.inc_index!
  env
end
save_key() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 25
def save_key
  if current =~ /^:\w+$/i
    @params[@index]= current.sub(/^:/, '')
    :ANY
  else
    current
  end
end
type() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 14
def type
  case @request_path_parts.last
  when Rack::App::Constants::PATH::APPLICATION
    :APPLICATION
  when Rack::App::Constants::PATH::MOUNT_POINT
    :MOUNT_POINT
  else
    :ENDPOINT
  end
end

Protected Instance Methods

clean_request_path_parts() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 63
def clean_request_path_parts
  @request_path_parts - SPECIAL_PATH_ELEMENTS
end
inc_index!() click to toggle source
# File lib/rack/app/router/tree/env.rb, line 54
def inc_index!
  @index += 1
end
request_path_parts_by(endpoint) click to toggle source
# File lib/rack/app/router/tree/env.rb, line 49
def request_path_parts_by(endpoint)
  u = Rack::App::Utils
  u.split_path_info(u.normalize_path(endpoint.request_path))
end