diff options
Diffstat (limited to 'blaunits.rb')
-rwxr-xr-x | blaunits.rb | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/blaunits.rb b/blaunits.rb index b8b00c8..13dc2aa 100755 --- a/blaunits.rb +++ b/blaunits.rb @@ -1,6 +1,6 @@ #!/usr/bin/ruby -VERSION = "2.0.1" +VERSION = "2.0.2" BINARY_NAME = "gunits" begin @@ -37,40 +37,40 @@ begin from = words[1] to = words[2] elsif words.length == 2 && mid == 0 - num = 1 - from = words[0] - to = words[1] + num = 1 + from = words[0] + to = words[1] elsif mid > 0 - for i in 1..mid-1 - from += words[i] - end - for i in mid+1..words.length-1 - to += words[i] - end - num = Float(words[0]) + for i in 1..mid-1 + from += words[i] + end + for i in mid+1..words.length-1 + to += words[i] + end + num = Float(words[0]) else - puts "Invalid input! Try !convert [amount] [from-unit] to [to-unit] e.g !convert 2 cm to inches" - exit + puts "Invalid input! Try !convert [amount] [from-unit] to [to-unit] e.g !convert 2 cm to inches" + exit end out = %x(#{BINARY_NAME} -t1 #{from} #{to}) outs = out.split(" ") if outs[0] == "Unknown" - from.upcase! - out = %x(#{BINARY_NAME} -t1 #{from} #{to}) - outs = out.split(" ") - if outs[0] == "Unknown" - to.upcase! - out = %x(#{BINARY_NAME} -t1 #{from} #{to}) - outs = out.split(" ") - if outs[0] == "Unknown" - puts out - exit - end - end + from.upcase! + out = %x(#{BINARY_NAME} -t1 #{from} #{to}) + outs = out.split(" ") + if outs[0] == "Unknown" + to.upcase! + out = %x(#{BINARY_NAME} -t1 #{from} #{to}) + outs = out.split(" ") + if outs[0] == "Unknown" + puts out + exit + end + end elsif outs[0] == "conformability" - puts "Incompatible units. Can't convert from #{from} to #{to}" - exit + puts "Incompatible units. Can't convert from #{from} to #{to}" + exit end puts "#{num} #{from} = #{num * Float(out)} #{to}" - + end
\ No newline at end of file |