Class: Wayfarer::CLI::RoutePrinter

Inherits:
Thor::Shell::Color
  • Object
show all
Defined in:
lib/wayfarer/cli/route_printer.rb

Constant Summary collapse

INDENT =
"   "
REGULAR_SEGMENT =
""
JUNCTION_SEGMENT =
"├──"
CORNER_SEGMENT =
"└──"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ RoutePrinter

Returns a new instance of RoutePrinter.



17
18
19
20
21
# File 'lib/wayfarer/cli/route_printer.rb', line 17

def initialize(url)
  @url = url
  @path_finder = Wayfarer::Routing::PathFinder.new(url)
  super()
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



6
7
8
# File 'lib/wayfarer/cli/route_printer.rb', line 6

def output
  @output
end

#path_finderObject (readonly)

Returns the value of attribute path_finder.



6
7
8
# File 'lib/wayfarer/cli/route_printer.rb', line 6

def path_finder
  @path_finder
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/wayfarer/cli/route_printer.rb', line 6

def url
  @url
end

Class Method Details



13
14
15
# File 'lib/wayfarer/cli/route_printer.rb', line 13

def self.print(route, url)
  route.accept(new(url))
end

Instance Method Details

#visit(route) ⇒ Object



23
24
25
26
27
# File 'lib/wayfarer/cli/route_printer.rb', line 23

def visit(route)
  route.accept(path_finder) unless route.parent
  puts format_route_output(route)
  true
end