Class: Racket::Router::Route

Inherits:
Struct
  • Object
show all
Defined in:
lib/racket/router.rb

Overview

A struct describing a route.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



28
29
30
# File 'lib/racket/router.rb', line 28

def action
  @action
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



28
29
30
# File 'lib/racket/router.rb', line 28

def params
  @params
end

#rootObject

Returns the value of attribute root

Returns:

  • (Object)

    the current value of root



28
29
30
# File 'lib/racket/router.rb', line 28

def root
  @root
end

Instance Method Details

#to_sObject



29
30
31
32
33
34
35
# File 'lib/racket/router.rb', line 29

def to_s
  route = root.dup
  route << "/#{action}" if action
  route << "/#{params.join('/')}" unless params.empty?
  route = route[1..-1] if route.start_with?('//') # Special case for root path
  route
end