class UrlGenerator def initialize(controller = nil) @controller = controller or ControllerStub.new end def make_file_link(mode, name, text, base_url, known_file) link = CGI.escape(name) case mode when :export if known_file then "#{text}" else "#{text}" end when :publish if known_file then "#{text}" else "#{text}" end else if known_file "#{text}" else "#{text}?" end end end def make_page_link(mode, name, text, base_url, known_page) link = CGI.escape(name) case mode.to_sym when :export if known_page then %{#{text}} else %{#{text}} end when :publish if known_page then %{#{text}} else %{#{text}} end else if known_page %{#{text}} else %{#{text}?} end end end def make_pic_link(mode, name, text, base_url, known_pic) link = CGI.escape(name) case mode.to_sym when :export if known_pic then %{#{text}} else %{#{text}} end when :publish if known_pic then %{#{text}} else %{#{text}} end else if known_pic then %{#{text}} else %{#{text}?} end end end end class ControllerStub end