File Size v3.0.0 FileSize.Calculable protocol View Source

A protocol that defines calculations that are possible on file sizes.

Link to this section Summary

Functions

Adds two file sizes.

Subtracts two file sizes.

Link to this section Types

Link to this section Functions

Link to this function

add(size, other_size) View Source
add(t(), t()) :: t()

Adds two file sizes.

Examples

iex> FileSize.add(FileSize.new(1, :kb), FileSize.new(2, :kb))
#FileSize<"3 kB">

iex> FileSize.add(FileSize.new(1, :b), FileSize.new(4, :bit))
#FileSize<"12 bit">

iex> FileSize.add(FileSize.new(4, :bit), FileSize.new(1, :b))
#FileSize<"12 bit">

iex> FileSize.add(FileSize.new(4, :mb), FileSize.new(200, :kb))
#FileSize<"4.2 MB">
Link to this function

subtract(size, other_size) View Source
subtract(t(), t()) :: t()

Subtracts two file sizes.

Examples

iex> FileSize.subtract(FileSize.new(3, :kb), FileSize.new(1, :kb))
#FileSize<"2 kB">

iex> FileSize.subtract(FileSize.new(1, :b), FileSize.new(4, :bit))
#FileSize<"0.5 B">