Class: Rack::App::Router::Tree::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/app/router/tree/env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



4
5
6
# File 'lib/rack/app/router/tree/env.rb', line 4

def endpoint
  @endpoint
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/rack/app/router/tree/env.rb', line 4

def params
  @params
end

#request_path_partsObject (readonly)

Returns the value of attribute request_path_parts.



4
5
6
# File 'lib/rack/app/router/tree/env.rb', line 4

def request_path_parts
  @request_path_parts
end

Instance Method Details

#branch?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rack/app/router/tree/env.rb', line 10

def branch?
  !clean_request_path_parts[@index..-2].empty?
end

#currentObject



6
7
8
# File 'lib/rack/app/router/tree/env.rb', line 6

def current
  @request_path_parts[@index]
end

#nextObject



34
35
36
37
38
# File 'lib/rack/app/router/tree/env.rb', line 34

def next
  env = self.dup
  env.inc_index!
  env
end

#save_keyObject



25
26
27
28
29
30
31
32
# 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

#typeObject



14
15
16
17
18
19
20
21
22
23
# 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