shortcode v0.4.0 Shortcode
Documentation for Shortcode
.
Link to this section Summary
Functions
Convert a shortcode to an integer.
Convert an uuid or an integer to a shortcode with support of prefix.
Convert a shortcode to a uuid.
Link to this section Functions
prefix_separator()
Specs
prefix_separator() :: binary()
to_integer(shortcode)
Specs
Convert a shortcode to an integer.
Examples
iex> Shortcode.to_integer("A") 36 iex> Shortcode.to_integer("0") 0 iex> Shortcode.to_integer("C8IF9cqY1HP7GGslHNYLI") 26867168257211004681214735068979920902 iex> Shortcode.to_integer("prefix_C8IF9cqY1HP7GGslHNYLI") 26867168257211004681214735068979920902
to_shortcode(uuid, prefix \\ nil)
Specs
to_shortcode(<<_::288>> | non_neg_integer(), nil | binary()) :: binary()
Convert an uuid or an integer to a shortcode with support of prefix.
Examples
iex> Shortcode.to_shortcode(0) "0" iex> Shortcode.to_shortcode(61) "Z" iex> Shortcode.to_shortcode("00000000-0000-0000-0000-000000000000") "0" iex> Shortcode.to_shortcode("14366daa-c0f5-0f52-c9ec-e0a0b1e20006") "C8IF9cqY1HP7GGslHNYLI" iex> Shortcode.to_shortcode("14366daa-c0f5-0f52-c9ec-e0a0b1e20006", "prefix") "prefix_C8IF9cqY1HP7GGslHNYLI"
to_uuid(shortcode)
Specs
to_uuid(binary()) :: <<_::288>>
Convert a shortcode to a uuid.
Examples
iex> Shortcode.to_uuid("") ** (FunctionClauseError) no function clause matching in Shortcode.to_uuid/1 iex> Shortcode.to_uuid("0") "00000000-0000-0000-0000-000000000000" iex> Shortcode.to_uuid("C8IF9cqY1HP7GGslHNYLI") "14366daa-c0f5-0f52-c9ec-e0a0b1e20006" iex> Shortcode.to_uuid("prefix_C8IF9cqY1HP7GGslHNYLI") "14366daa-c0f5-0f52-c9ec-e0a0b1e20006"