Class: Controller
- Inherits:
-
Object
- Object
- Controller
- Defined in:
- lib/colorized_routes/controller.rb
Overview
module ColorizedRoutes
Instance Method Summary collapse
- #display(widths) ⇒ Object
-
#initialize(routes, name) ⇒ Controller
constructor
The controller will have many routes.
Constructor Details
#initialize(routes, name) ⇒ Controller
The controller will have many routes
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/colorized_routes/controller.rb', line 5 def initialize routes, name if name.include? "/" parts = name.split("/") @name = parts.last @namespaces = parts.take(parts.size - 1) else @name = name @namespaces = [] end @routes = routes end |
Instance Method Details
#display(widths) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/colorized_routes/controller.rb', line 17 def display widths space_counter = 0 if @namespaces.any? @namespaces.each do |ns| unless space_counter == 0 print "#{Array(1..space_counter).map{|s| " "}.join}" end print "Namespace: ".light_white puts " #{ns} ".light_white.on_light_red.bold space_counter += 1 end end unless space_counter == 0 print "#{Array(1..space_counter).map{|s| " "}.join}" end print "Controller: ".light_white if @namespaces.any? print " #{@name} ".light_white.on_blue.bold print " => ".light_white puts " #{[@namespaces.join("/"),@name].join("/")} ".light_white.on_blue.bold else puts " #{@name} ".light_white.on_blue.bold end @routes.each {|r| r.display(widths)} puts "" end |