aboutsummaryrefslogtreecommitdiffstats
path: root/pressure/pressure.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2022-05-27 22:39:03 -0230
committerSam Anthony <sam@samanthony.xyz>2022-05-27 22:39:03 -0230
commit31605150d3e10b08dad2086005c64664f5648a51 (patch)
tree7419f90e7b30d3de52595f25852e9ef87094718c /pressure/pressure.go
parent585fbf852c1e76470df42ebe99ede62440ce19d9 (diff)
downloadvolute-31605150d3e10b08dad2086005c64664f5648a51.zip
prepare to switch ui library
Diffstat (limited to 'pressure/pressure.go')
-rw-r--r--pressure/pressure.go38
1 files changed, 3 insertions, 35 deletions
diff --git a/pressure/pressure.go b/pressure/pressure.go
index da1ab1e..820a8cf 100644
--- a/pressure/pressure.go
+++ b/pressure/pressure.go
@@ -1,10 +1,5 @@
package pressure
-import (
- "errors"
- "fmt"
-)
-
type Pressure float32
const (
@@ -14,35 +9,8 @@ const (
PoundsPerSquareInch Pressure = 6_894.757
)
-// UnitStrings returns a slice of strings, each representing a
-// unit.
-// This is necessary because giu.Combo only works with strings.
-func UnitStrings() []string {
- return []string{"Pa", "kPa", "bar", "psi"}
-}
-
-const (
- DefaultUnit Pressure = Kilopascal
- // DefaultUnitIndex is used to index UnitStrings().
- DefaultUnitIndex int32 = 1 // kPa
-)
-
-func UnitFromString(s string) (Pressure, error) {
- // Each case corresponds to a value in UnitStrings().
- switch s {
- case "Pa":
- return Pascal, nil
- case "kPa":
- return Kilopascal, nil
- case "bar":
- return Bar, nil
- case "psi":
- return PoundsPerSquareInch, nil
- default:
- return *new(Pressure), errors.New(fmt.Sprintf("invalid unit: '%s'", s))
- }
+func (p Pressure) As(unit Pressure) float32 {
+ return float32(p / unit)
}
-func Atmospheric() Pressure {
- return 1 * Bar
-}
+const Atmospheric = Bar