class Navigable::Router::Printer

Constants

VERBS

Attributes

dynamic[R]
memo[R]
static[R]
stdout[R]

Public Class Methods

new(static, dynamic, stdout = STDOUT) click to toggle source
# File lib/navigable/router/printer.rb, line 10
def initialize(static, dynamic, stdout = STDOUT)
  @static, @dynamic = static, dynamic
  @stdout = stdout
  @memo = []
end

Public Instance Methods

print() click to toggle source

Private Instance Methods

gather_dynamic_routes() click to toggle source
# File lib/navigable/router/printer.rb, line 32
def gather_dynamic_routes
  dynamic.each do |verb, trie|
    trie.print(verb, memo)
  end
end
gather_static_routes() click to toggle source
# File lib/navigable/router/printer.rb, line 24
def gather_static_routes
  static.each do |verb, routes|
    routes.each do |path, endpoint|
      memo << { verb: verb, path: path, endpoint: endpoint }
    end
  end
end
pad(str, length) click to toggle source
# File lib/navigable/router/printer.rb, line 50
def pad(str, length)
  "%#{length}s" % str
end
print_route(route) click to toggle source
print_routes() click to toggle source
sorted_routes() click to toggle source
# File lib/navigable/router/printer.rb, line 42
def sorted_routes
  memo.sort_by { |route| "#{route[:path]}-#{VERBS.find_index(route[:verb])}" }
end