Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Backwards compatibility with 1.8.7

  • Loading branch information...
commit 0fd4557e343198d4e28b9f829dd943efa00458f6 1 parent d97323d
Josep M. Bach authored January 09, 2011
4  lib/rpn/parser.rb
@@ -13,7 +13,7 @@ def initialize delimiter
13 13
     end
14 14
 
15 15
     def parse string
16  
-      string.gsub(/#{delimiter}+/, delimiter)
  16
+      string.gsub(/#{delimiter}+/, delimiter)\
17 17
             .split(delimiter).map(&:strip).map do |element|
18 18
         if element.to_i.zero? && element != '0'
19 19
           if TOKENS.include?(element)
@@ -22,7 +22,7 @@ def parse string
22 22
             raise MalformedStringError.new("Offending token: #{element}")
23 23
           end
24 24
         else
25  
-          element =~ /\./ ? element.to_f
  25
+          element =~ /\./ ? element.to_f\
26 26
                           : element.to_i
27 27
         end
28 28
       end
5  lib/rpn/stack.rb
@@ -17,14 +17,15 @@ def solve tokens
17 17
           push token
18 18
           next
19 19
         end
20  
-        raise InsufficientValuesAvailable
  20
+        raise InsufficientValuesAvailable\
21 21
               .new("Cannot apply #{token} to less than #{arity} values!") if size < arity
22 22
         result = pop(arity).inject do |acc, e|
23 23
           acc.send(token, e)
24 24
         end
25 25
         push result
26 26
       end
27  
-      raise UnsolvableExpressionError.new("The final stack contained more than one value: #{elements.inspect}") if size > 1
  27
+      raise UnsolvableExpressionError\
  28
+            .new("The final stack contained more than one value: #{elements.inspect}") if size > 1
28 29
       elements.first
29 30
     end
30 31
 

0 notes on commit 0fd4557

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