Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Created March 11, 2009 03:50
Show Gist options
  • Save jacaetevha/77299 to your computer and use it in GitHub Desktop.
Save jacaetevha/77299 to your computer and use it in GitHub Desktop.
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