Created
March 19, 2014 14:21
-
-
Save ColinTheRobot/9642615 to your computer and use it in GitHub Desktop.
sinatra_calc(not working still)
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
require 'sinatra' | |
require 'sinatra/reloader' if development? | |
require 'pry' | |
get "/" do | |
"Welcome to this wicked CAL-cu-LAY-torrrr....\n\n" | |
end | |
# def shove_it(shove_it) | |
# @array = Array.new | |
# @array.push(shove_it) | |
# end | |
array = [] | |
def show_it | |
array.map { |calculation| puts calculation } | |
end | |
get "/calculator" do | |
show_it | |
end | |
get "/calculator/3" do | |
#should show the third calculations | |
end | |
post "/calculator/add" do | |
binding.pry | |
calculation = params[:first].to_f + params[:second].to_f | |
array << "#{params[:first]} + #{params[:second]} = #{calculation}" | |
binding.pry | |
"#{params[:first]} + #{params[:second]} = #{calculation}\n\n" | |
binding.pry | |
end | |
post "/calculator/subtract" do | |
calculation = params[:first].to_f - params[:second].to_f | |
"#{params[:first]} - #{params[:second]} = #{calculation}\n\n" | |
end | |
post "/calculator/multiply" do | |
calculation = params[:first].to_f * params[:second].to_f | |
"#{params[:first]} * #{params[:second]} = #{calculation}\n\n" | |
end | |
post "/calculator/divide" do | |
calculation = params[:first].to_f / params[:second].to_f | |
"#{params[:first]} / #{params[:second]} = #{calculation}\n\n" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment