Skip to content

Commit

Permalink
docs: polish it
Browse files Browse the repository at this point in the history
  • Loading branch information
c4710n committed Aug 24, 2024
1 parent d9dc954 commit f106c74
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/cozy_size.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,28 @@ defmodule CozySize do
* `CozySize.IEC`
* `CozySize.JEDEC`
## Usage
iex> # get bytes by following IEC standard
iex> bytes = CozySize.IEC.to_bytes({1024, :MiB})
iex> # get a humanized tuple by following IEC standard
iex> CozySize.IEC.from_bytes(bytes)
{1, :GiB}
iex> # get a humanized tuple by following JEDEC standard
iex> CozySize.JEDEC.from_bytes(bytes)
{1, :GB}
iex> # get a humanized tuple by following JEDEC standard
iex> CozySize.SI.from_bytes(bytes)
{1.07, :GB}
If you want to operate on bits, please check the `*_bits` functions in each module,
which will not be further elaborated here.
"""

@type bits :: number()
@type bytes :: number()

@type from_opt :: {:as, :bits | :bytes} | {:precision, integer()}
@type from_opt :: {:as, :bits | :bytes} | {:precision, pos_integer()}
@type from_opts :: [from_opt()]
end

0 comments on commit f106c74

Please sign in to comment.