I think you really need to be looking at a proper parser using a define grammar. Something like the lex/yacc solution. I'm not really conversant with ruby but it seems there are some ruby implementations
http://www.ruby-doc.org/stdlib-2.1.0/libdoc/racc/parser/rdoc/Racc.html http://i.loveruby.net/en/projects/racc/doc/
You can treat a space as an operator which functions like addition. On top of rules for the standard mathematical operators you might have
exp: exp ' ' exp { result = val[0] + val1 } | exp '+' exp { result = val[0] + val1 } | exp '-' exp { result = val[0] - val1 } | exp '*' exp { result = val[0] * val1 } | exp '/' exp { result = val[0] / val1 }
You will need to add precedence rules and rules for coping with the units of measurement.
An alternative to that would be to implement a Shunting-yard algorithm which can parse mathematical expressions.