https://github.com/seniverse/ucumex
https://github.com/seniverse/ucumex
convert elixir unit
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/seniverse/ucumex
- Owner: seniverse
- Created: 2019-12-25T12:09:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-02T06:50:48.000Z (almost 6 years ago)
- Last Synced: 2025-01-04T16:42:33.886Z (over 1 year ago)
- Topics: convert, elixir, unit
- Language: Erlang
- Size: 45.9 KB
- Stars: 0
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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")
```