Sha256: b92f7b3e8c1c2cecb0af465439dc1510194e53d4dd79a0062fa2fb7eb0dc95c6
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
#module ColorizedRoutes class Controller # The controller will have many routes 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 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 end #end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
colorized_routes-0.2.1 | lib/colorized_routes/controller.rb |
colorized_routes-0.2.0 | lib/colorized_routes/controller.rb |