aboutsummaryrefslogtreecommitdiffstats
path: root/volume/volume.go
blob: 4eb22fe1c204404112575f08a36921a0a6a3cca8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package volume

type Volume float32

const (
	CubicCentimetre Volume = 1
	Litre           Volume = 1_000
	CubicMetre      Volume = 1_000_000
	CubicInch       Volume = 16.38706
)

func New(i float32, u Volume) Volume {
	return Volume(i) * u
}

func (v Volume) As(unit Volume) float32 {
	return float32(v / unit)
}