CSSEx.Unit (CSSEx v0.6.6) View Source

A basic representation to use for CSS units.

Link to this section 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

Link to this section Functions

Specs

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