Class: ValidRoute::RouteFormatter
- Inherits:
-
Object
- Object
- ValidRoute::RouteFormatter
- Defined in:
- lib/valid_route/route_formatter.rb
Instance Method Summary collapse
- #header(routes) ⇒ Object
-
#initialize ⇒ RouteFormatter
constructor
A new instance of RouteFormatter.
- #no_routes ⇒ Object
- #result ⇒ Object
- #section(routes) ⇒ Object
-
#section_title(title) ⇒ Object
only called for engines.
Constructor Details
#initialize ⇒ RouteFormatter
Returns a new instance of RouteFormatter.
3 4 5 6 7 8 |
# File 'lib/valid_route/route_formatter.rb', line 3 def initialize @buffer = [] @current_route_set = nil @main_app_routes = [] @engine_routes = [] end |
Instance Method Details
#header(routes) ⇒ Object
32 33 |
# File 'lib/valid_route/route_formatter.rb', line 32 def header(routes) end |
#no_routes ⇒ Object
35 36 37 |
# File 'lib/valid_route/route_formatter.rb', line 35 def no_routes @buffer end |
#result ⇒ Object
10 11 12 |
# File 'lib/valid_route/route_formatter.rb', line 10 def result @buffer #.compact.uniq end |
#section(routes) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/valid_route/route_formatter.rb', line 21 def section(routes) formatted_routes = array_paths(routes) if @main_app_routes.empty? @main_app_routes = formatted_routes else @engine_routes << formatted_routes end @buffer << formatted_routes @buffer.flatten! end |
#section_title(title) ⇒ Object
only called for engines
14 15 16 17 18 19 |
# File 'lib/valid_route/route_formatter.rb', line 14 def section_title(title) # only called for engines engine_regexp = /Routes for (.*)/ if title.match(engine_regexp) @current_route_set = title.slice(engine_regexp,1) end end |