MiseEnPlace
MiseEnPlace 是一个用于将烹饪中常用的度量转换和解释的框架。
MeasurementUnit.swift
MeasurementUnit
枚举是 MiseEnPlace 框架的核心。这个枚举代表了一种度量单位,以及它所属的 MeasurementSystem
和 MeasurementMethod
。
转换到其他单位和数量以及何时进行转换的所有逻辑都包含在这个枚举中。
MeasurementMethod.swift
MeasurementMethod
表示如何进行测量的方式。在 MiseEnPlace 框架的案例中,这意味着 Volume
(体积)和 Mass
(质量)。
MeasurementSystem.swift
类似于 MeasurementMethod
,MeasurementSystem
枚举表示可以使用的单位系统类型。目前只支持 US
(美国)和 Metric
(公制)。
MeasurementSystemMethod.swift
MeasurementSystemMethod
表示了如何组合 MeasurementMethod
和 MeasurementSystem
。
Convertable.swift
Convertable
协议定义了执行转换和翻译所需的属性。协议的扩展提供了许多基于比率进行测量缩放的重要方法。
CookingMeasurement.swift
表示一个量和单位的配对。一个 CookingMeasurement
拥有多个关键的属性和函数,用于翻译可读性字符串。
Ratio.swift
体积和重量之间的关系。
Double+MiseEnPlace.swift
Double
的一个扩展,提供了确定值质量和在同一 MeasurementSystemMethod
内将一个量转换成另一个量的函数。
Fraction.swift
在 MiseEnPlace
框架中使用的分数值枚举。
Intergral.swift
一个包含常见积分值的枚举。主要用于iOS的MeasurementInputView。