// =============================================================================
// Concentration
// =============================================================================

#[pyclass(name = "Concentration", module = "entropyk")]
#[derive(Clone)]
pub struct PyConcentration {
    pub(crate) inner: entropyk::Concentration,
}

#[pymethods]
impl PyConcentration {
    #[staticmethod]
    fn from_percent(value: f64) -> Self {
        PyConcentration {
            inner: entropyk::Concentration::from_percent(value),
        }
    }

    #[staticmethod]
    fn from_fraction(value: f64) -> Self {
        PyConcentration {
            inner: entropyk::Concentration::from_fraction(value),
        }
    }

    fn to_percent(&self) -> f64 {
        self.inner.to_percent()
    }

    fn to_fraction(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn to_mass_fraction(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn __repr__(&self) -> String {
        format!("Concentration({:.2}%)", self.inner.to_percent())
    }

    fn __float__(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn __eq__(&self, other: &PyConcentration) -> bool {
        (self.inner.0 - other.inner.0).abs() < 1e-10
    }
}

// =============================================================================
// VolumeFlow
// =============================================================================

#[pyclass(name = "VolumeFlow", module = "entropyk")]
#[derive(Clone)]
pub struct PyVolumeFlow {
    pub(crate) inner: entropyk::VolumeFlow,
}

#[pymethods]
impl PyVolumeFlow {
    #[staticmethod]
    fn from_m3_per_s(value: f64) -> Self {
        PyVolumeFlow { inner: entropyk::VolumeFlow::from_m3_per_s(value) }
    }

    #[staticmethod]
    fn from_l_per_min(value: f64) -> Self {
        PyVolumeFlow { inner: entropyk::VolumeFlow::from_l_per_min(value) }
    }

    fn to_m3_per_s(&self) -> f64 {
        self.inner.to_m3_per_s()
    }

    fn to_l_per_min(&self) -> f64 {
        self.inner.to_l_per_min()
    }

    fn __repr__(&self) -> String {
        format!("VolumeFlow({:.6} m³/s)", self.inner.to_m3_per_s())
    }

    fn __float__(&self) -> f64 {
        self.inner.to_m3_per_s()
    }

    fn __eq__(&self, other: &PyVolumeFlow) -> bool {
        (self.inner.0 - other.inner.0).abs() < 1e-15
    }
}

// =============================================================================
// RelativeHumidity
// =============================================================================

#[pyclass(name = "RelativeHumidity", module = "entropyk")]
#[derive(Clone)]
pub struct PyRelativeHumidity {
    pub(crate) inner: entropyk::RelativeHumidity,
}

#[pymethods]
impl PyRelativeHumidity {
    #[staticmethod]
    fn from_percent(value: f64) -> Self {
        PyRelativeHumidity { inner: entropyk::RelativeHumidity::from_percent(value) }
    }

    #[staticmethod]
    fn from_fraction(value: f64) -> Self {
        PyRelativeHumidity { inner: entropyk::RelativeHumidity::from_fraction(value) }
    }

    fn to_percent(&self) -> f64 {
        self.inner.to_percent()
    }

    fn to_fraction(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn __repr__(&self) -> String {
        format!("RelativeHumidity({:.2}%)", self.inner.to_percent())
    }

    fn __float__(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn __eq__(&self, other: &PyRelativeHumidity) -> bool {
        (self.inner.0 - other.inner.0).abs() < 1e-10
    }
}

// =============================================================================
// VaporQuality
// =============================================================================

#[pyclass(name = "VaporQuality", module = "entropyk")]
#[derive(Clone)]
pub struct PyVaporQuality {
    pub(crate) inner: entropyk::VaporQuality,
}

#[pymethods]
impl PyVaporQuality {
    #[staticmethod]
    fn from_fraction(value: f64) -> Self {
        PyVaporQuality { inner: entropyk::VaporQuality::from_fraction(value) }
    }

    #[staticmethod]
    fn from_percent(value: f64) -> Self {
        PyVaporQuality { inner: entropyk::VaporQuality::from_percent(value) }
    }

    fn to_fraction(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn to_percent(&self) -> f64 {
        self.inner.to_percent()
    }

    fn __repr__(&self) -> String {
        format!("VaporQuality({:.2}%)", self.inner.to_percent())
    }

    fn __float__(&self) -> f64 {
        self.inner.to_fraction()
    }

    fn __eq__(&self, other: &PyVaporQuality) -> bool {
        (self.inner.0 - other.inner.0).abs() < 1e-10
    }
}

