summaryrefslogtreecommitdiff
path: root/blaunits.rb
diff options
context:
space:
mode:
Diffstat (limited to 'blaunits.rb')
-rwxr-xr-xblaunits.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/blaunits.rb b/blaunits.rb
index 13dc2aa..8c08e0f 100755
--- a/blaunits.rb
+++ b/blaunits.rb
@@ -1,7 +1,7 @@
#!/usr/bin/ruby
-VERSION = "2.0.2"
-BINARY_NAME = "gunits"
+VERSION = "2.1.0"
+BINARY_NAME = "units"
begin
args = ARGV.dup
@@ -52,6 +52,13 @@ begin
puts "Invalid input! Try !convert [amount] [from-unit] to [to-unit] e.g !convert 2 cm to inches"
exit
end
+ if from == "F" && to == "C"
+ temp = (num - 32) / 1.8
+ puts "#{num} F = #{temp} C"
+ elsif from == "C" && to == "F"
+ temp = (num * 1.8) + 32
+ puts "#{num} C = #{temp} F"
+ else
out = %x(#{BINARY_NAME} -t1 #{from} #{to})
outs = out.split(" ")
if outs[0] == "Unknown"
@@ -72,5 +79,5 @@ begin
exit
end
puts "#{num} #{from} = #{num * Float(out)} #{to}"
-
-end \ No newline at end of file
+ end
+end