diff options
| author | Joe Robinson <joe@lc8n.com> | 2017-05-15 18:51:42 +0100 | 
|---|---|---|
| committer | Joe Robinson <joe@lc8n.com> | 2017-05-15 18:51:42 +0100 | 
| commit | 0aa1e642d1ce0950b1dd34c92d4436be9efee8c0 (patch) | |
| tree | a44f31bdf15dea097c78cb9a6e881f406086eb69 /blaunits.rb | |
| parent | 317df7075f8c2ec5e525db7c2237b85dc8653073 (diff) | |
Add support for C/F temperature calculations using hard coded formula
Diffstat (limited to 'blaunits.rb')
| -rwxr-xr-x | blaunits.rb | 15 | 
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 | 
