An open API service indexing awesome lists of open source software.

https://github.com/seniverse/ucumex


https://github.com/seniverse/ucumex

convert elixir unit

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# Ucumex

A elixir lib according to [THE UNIFIED CODE FOR UNITS OF MEASURE](http://unitsofmeasure.org/ucum.html) to convert unit.

## Note!

- **Comment is not Supported**
- **Special Units are not Supported Except Fahrenheit Degree and Celsius Degree**

## Examples

```elixir
{:ok, op} = Ucumex.convertor("km", "m")

op.(3) # -> 3.0e3
```

```elixir
# "[degRe]" is special unit
Ucumex.convertor("km", "[degRe]")

** (NotImplementedError) handler is not implemented for this special unit.
(ucumex) lib/ucumex.ex:390: Ucumex.to_basic_units/1
(ucumex) lib/ucumex.ex:48: Ucumex.to_bin_op/2
(ucumex) lib/ucumex.ex:24: Ucumex.unit_to_std/1
(ucumex) lib/ucumex.ex:17: Ucumex.convertor/2
```

```elixir
{:error, :unit_not_match} = Ucumex.convertor("km", "L")
```