Skip to content

Commit

Permalink
Merge pull request #6 from randallreedjr/chore/rename-controller
Browse files Browse the repository at this point in the history
Rename Math24Controller to GetTo24Controller
  • Loading branch information
randallreedjr committed Jan 24, 2017
2 parents 0b0d62f + ff40797 commit fc70245
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class Math24Controller < ApplicationController
class GetTo24Controller < ApplicationController
get '/' do
erb :'math24/index'
erb :'get_to_24/index'
end

get '/about' do
erb :'math24/about'
erb :'get_to_24/about'
end

get '/problem' do
problem = Math24.generate_problem.join(" ")
erb :'math24/problem', :locals => {:problem => problem}
erb :'get_to_24/problem', :locals => {:problem => problem}
end

get '/solve' do
erb :'math24/solve', :locals => {:invalid => false}
erb :'get_to_24/solve', :locals => {:invalid => false}
end

post '/solution' do
Expand All @@ -31,11 +31,11 @@ class Math24Controller < ApplicationController
if valid
solution = Math24.solve(numbers)
message = solution ? "#{solution} = 24" : "No solution found"
erb :'math24/solution', :locals => {:problem => numbers.join(" "),
erb :'get_to_24/solution', :locals => {:problem => numbers.join(" "),
:message => message,
:last_answer => 24}
else
erb :'math24/solve', :locals => {:invalid => true}
erb :'get_to_24/solve', :locals => {:invalid => true}
end
end

Expand All @@ -52,17 +52,17 @@ class Math24Controller < ApplicationController
end

if valid_solution
erb :'math24/correct',
erb :'get_to_24/correct',
:locals => {
:problem => problem,
:solution => solution
}
elsif error
erb :'math24/incorrect', :locals => {:problem => problem,
erb :'get_to_24/incorrect', :locals => {:problem => problem,
:solution => solution,
:last_answer => '???'}
else
erb :'math24/incorrect', :locals => {:problem => problem,
erb :'get_to_24/incorrect', :locals => {:problem => problem,
:solution => solution,
:last_answer => instance_eval(solution)}
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ require './config/environment.rb'

use Rack::Static, :urls => ['/css', '/js'], :root => 'public'
use Rack::MethodOverride
use Math24Controller
run ApplicationController
use GetTo24Controller
run ApplicationController
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def app
Math24Controller
GetTo24Controller
end

describe Math24Controller, :type => :controller do
describe GetTo24Controller, :type => :controller do
describe 'get /' do
it 'renders the home page' do
get '/'
Expand Down

0 comments on commit fc70245

Please sign in to comment.