Skip to content
Browse files

Creating OPERATORS hash in CalculatorOperations module and removing t…

…he hardcoded value in calculations.rb
  • Loading branch information...
1 parent 0fb77c6 commit 3f8d9716ac1981ff3f22cdedb0393c3767936b36 @bishboria bishboria committed Sep 10, 2011
View
6 Examples/Calculator/features/lib/default/tasks/reference/calculations.rb
@@ -1,14 +1,16 @@
+require 'calculator_operations'
+
module Calculations
def follow_the_steps_for sum
enter_numbers_and_operators_for sum
end
def enter_numbers_and_operators_for sum
- operator = {"+" => :plus, "-" => :minus, "=" => :equals}
+ operators = CalculatorOperations::OPERATORS
sum.each do | token |
enter token.to_i if token =~ /\d+/
- press operator[token] if operator.include? token
+ press operators[token] if operators.include? token
end
end
end
View
1 Examples/Calculator/lib/calculator_operations.rb
@@ -1,3 +1,4 @@
module CalculatorOperations
+ OPERATORS = { '+' => :plus, '-' => :minus, '=' => :equals }
OPERATIONS = { 'plus' => :+, 'minus' => :-, 'equals' => '=' }
end

0 comments on commit 3f8d971

Please sign in to comment.
Something went wrong with that request. Please try again.