Tolerance to bad casing; added 'Ra' as acceptable unit

pull/2/head
Aaron Johnson 6 years ago
parent 74fec40e64
commit 96ffc16155

@ -128,8 +128,9 @@ if @tunit.nil?
puts "Error(#{errcount.to_s}): Temperature units not configured! Defaulting to Rankine. Continuing...\n\n" puts "Error(#{errcount.to_s}): Temperature units not configured! Defaulting to Rankine. Continuing...\n\n"
@tunit = 'R' @tunit = 'R'
else else
case @tunit case @tunit.upcase
when "C", "F", "K", "R" when "C", "F", "K", "R", "RA"
@tunit = @tunit.capitalize
print "OK\n".green.bold print "OK\n".green.bold
else else
errcount += 1 errcount += 1
@ -202,14 +203,14 @@ def process_tdata(host, simple=false)
#if tdata.is_integer? #if tdata.is_integer?
if tdata.is_float? if tdata.is_float?
tdf = tdata.to_f tdf = tdata.to_f
case @tunit case @tunit.upcase
when "C" when "C"
#Do nothing; expected input is Celsius #Do nothing; expected input is Celsius
when "F" when "F"
tdf = (tdf * 1.8) + 32 tdf = (tdf * 1.8) + 32
when "K" when "K"
tdf = tdf + 273.15 tdf = tdf + 273.15
when "R" when "R", "RA"
tdf = (tdf * 1.8) + 491.67 tdf = (tdf * 1.8) + 491.67
else else
puts "#{@tunit} not valid temperature unit! Submitting unmodified output!" puts "#{@tunit} not valid temperature unit! Submitting unmodified output!"

Loading…
Cancel
Save