View Source CSSEx.Unit (CSSEx v1.0.2)

A basic representation to use for CSS units.

Summary

Functions

Accepts a String.t and Generates a %CSSEx.Unit{} with an appropriate unit set if it matches any of the predefined units, otherwise a struct with unit set to nil when there's no unit, or an error if there's a unit but isn't a valid one. If the argument can't be parsed as a float it returns an :error tuple

Functions

@spec new_unit(String.t()) ::
  %CSSEx.Unit{unit: term(), value: term()} | {:error, atom()}

Accepts a String.t and Generates a %CSSEx.Unit{} with an appropriate unit set if it matches any of the predefined units, otherwise a struct with unit set to nil when there's no unit, or an error if there's a unit but isn't a valid one. If the argument can't be parsed as a float it returns an :error tuple