Title / Description
Code class Router class Route attr_accessor :name,:path def initialize(name,path) @name = name @path = path end def to_s "#{@name}-->#{@path}" end end attr_accessor :routes def initialize(&block) @routes = [] instance_eval &block end def add(name,path) @routes << Route.new(name,path) end def default(path) @routes << Route.new(:root,path) end end router=Router.new do |r| add :ciao, '/ciao' add :hello, '/hello' default '/' end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code