{lhs: "1 U.S. dollar",rhs: "1 101.32159 South Korean won",error: "",icc: true}
Using a split(' ')[0] method will result in an incorrect value of 1, instead of 1101.32159.
I've modified the code to call gsub(/[^\d.]/, '') to strip out any non-digit characters, while leaving in the decimal place. This will convert a returned rhs value of "1 101.32159 South Korean won" to "1101.32159"
The fetch_rate methods improperly parses results from google currency when the returned value is greater than 1000.
For example, USD to KRW (S. Korean Won) has an exchange rate of 1 to 1101.32159. The JSON response from Google (http://www.google.com/ig/calculator?hl=en&q=1USD=?KRW) looks like so:
{lhs: "1 U.S. dollar",rhs: "1 101.32159 South Korean won",error: "",icc: true}
Using a split(' ')[0] method will result in an incorrect value of 1, instead of 1101.32159.
I've modified the code to call gsub(/[^\d.]/, '') to strip out any non-digit characters, while leaving in the decimal place. This will convert a returned rhs value of "1 101.32159 South Korean won" to "1101.32159"
Very handy library, much thanks!