Merge pull request #175 from BennyDaBee/patch-1

Update measurement.js
This commit is contained in:
Michael Woods 2022-06-22 20:55:34 -04:00 committed by GitHub
commit 9a5daf33c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,9 @@ class Measurement {
'°C', '°C',
'km', 'km',
'kPa', 'kPa',
'km/l(e)' 'km/l(e)',
// Helps with conversion to Gallons.
'lit'
]; ];
constructor(value, unit) { constructor(value, unit) {
@ -35,6 +37,8 @@ class Measurement {
case 'volts': case 'volts':
case 'Volts': case 'Volts':
return 'V'; return 'V';
case 'l':
return 'lit';
// these are states // these are states
case 'Stat': case 'Stat':
case 'N/A': case 'N/A':
@ -66,6 +70,9 @@ class Measurement {
// km/L = (1.609344 / 3.785411784) * MPG // km/L = (1.609344 / 3.785411784) * MPG
value = _.round(value / (1.609344 / 3.785411784), 1); value = _.round(value / (1.609344 / 3.785411784), 1);
break; break;
case 'lit':
value = _.round(value / 3.785411784, 1);
break;
} }
return value; return value;
} }
@ -85,6 +92,8 @@ class Measurement {
return 'psi'; return 'psi';
case 'km/l(e)': case 'km/l(e)':
return 'mpg(e)'; return 'mpg(e)';
case 'lit':
return 'gal';
default: default:
return unit; return unit;
} }