Created
March 11, 2009 03:50
-
-
Save jacaetevha/77299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/sqrt/:num.:format' do | |
model = Math.sqrt(params[:num].to_f) | |
content_type params[:format].to_sym | |
format(model, params, self) | |
end | |
def format(model, params, app) | |
if %w{xml json pdf xls csv html}.include? params[:format] | |
app.send(params[:format], model) | |
else | |
model.inspect | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment