deordinalize v0.1.0 Deordinalize View Source
"Deordinalizes" strings into the integers they reference.
Link to this section Summary
Functions
"Deordinalize" a string into the integer it references and converts to a zero-based index. For the time being, only supports ordinals from 1 to 100.
"Deordinalize" a string into the integer it references
and converts to a zero-based index. For the time being,
only supports ordinals from 1 to 100. Raises an ArgumentError
if the input is not a String representing a valid ordinal.
"Deordinalize" a string into the integer it references. For the time being, only supports ordinals from 1 to 100.
"Deordinalize" a string into the integer it references.
For the time being, only supports ordinals from 1 to 100.
Raises an ArgumentError
if the input is not a String
representing a valid ordinal.
Link to this section Functions
"Deordinalize" a string into the integer it references and converts to a zero-based index. For the time being, only supports ordinals from 1 to 100.
## Examples
iex> "1st" |> Deordinalize.to_index
{:ok, 0}
iex> "ninety-ninth" |> Deordinalize.to_index
{:ok, 98}
iex> "badnumth" |> Deordinalize.to_index
{:error, "argument must be a valid ordinal"}
"Deordinalize" a string into the integer it references
and converts to a zero-based index. For the time being,
only supports ordinals from 1 to 100. Raises an ArgumentError
if the input is not a String representing a valid ordinal.
Examples
iex> "1st" |> Deordinalize.to_index!
0
iex> "11th" |> Deordinalize.to_index!
10
iex> "first" |> Deordinalize.to_index!
0
iex> "ninety-ninth" |> Deordinalize.to_index!
98
"Deordinalize" a string into the integer it references. For the time being, only supports ordinals from 1 to 100.
Examples
iex> "1st" |> Deordinalize.to_integer
{:ok, 1}
iex> "garbage" |> Deordinalize.to_integer
{:error, "argument must be a valid ordinal"}
"Deordinalize" a string into the integer it references.
For the time being, only supports ordinals from 1 to 100.
Raises an ArgumentError
if the input is not a String
representing a valid ordinal.
Examples
iex> "1st" |> Deordinalize.to_integer!
1
iex> "11th" |> Deordinalize.to_integer!
11
iex> "16th" |> Deordinalize.to_integer!
16
iex> "20th" |> Deordinalize.to_integer!
20
iex> "21st" |> Deordinalize.to_integer!
21
iex> "99th" |> Deordinalize.to_integer!
99
iex> "first" |> Deordinalize.to_integer!
1
iex> "eleventh" |> Deordinalize.to_integer!
11
iex> "sixteenth" |> Deordinalize.to_integer!
16
iex> "twentieth" |> Deordinalize.to_integer!
20
iex> "twenty-first" |> Deordinalize.to_integer!
21
iex> "ninety-ninth" |> Deordinalize.to_integer!
99