Skip to content

Commit

Permalink
update parser to directly perform the conversion to a complex for rub…
Browse files Browse the repository at this point in the history
…ies that don't define it on string (like 1.8)
  • Loading branch information
olbrich committed Apr 23, 2011
1 parent 1b3fa0c commit 2218bf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ruby_units/unit.rb
Expand Up @@ -1237,7 +1237,11 @@ def self.parse_into_numbers_and_units(string)
when NilClass
1
when complex
num.to_c
if num.respond_to?(:to_c)
num.to_c
else
Complex(*num.scan(/(#{sci})(#{sci})i/).flatten.map {|n| n.to_i})
end
when rational
Rational(*num.split("/").map {|x| x.to_i})
else
Expand Down

0 comments on commit 2218bf7

Please sign in to comment.