Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.35 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.35 KB

Deordinalize

A small package to "deordinalize" strings into the integers they reference. Ported from Jeremy Ruppel's deordinalize Ruby gem.

Installation:

The package can be installed by adding deordinalize to your list of dependencies in mix.exs:

def deps do
  [
    {:deordinalize, "~> 0.1.1"}
  ]
end

Usage:

Deordinalize, for the time being, only supports ordinals from 1 to 100.

We can deordinalize numeric ordinals:

	"1st" |> Deordinalize.to_integer   # => 1
	"11th" |> Deordinalize.to_integer  # => 11
	"99th" |> Deordinalize.to_integer  # => 99

Or we can deordinalize more verbose ordinals:

	"first" |> Deordinalize.to_integer         # => 1
	"eleventh" |> Deordinalize.to_integer      # => 11
	"ninety-ninth" |> Deordinalize.to_integer  # => 99

Use to_index to get the zero-based index of your ordinal:

	"first" |> Deordinalize.to_integer!         # => 0
	"eleventh" |> Deordinalize.to_integer!      # => 10
	"ninety-ninth" |> Deordinalize.to_integer!  # => 98

The docs can be found at https://hexdocs.pm/deordinalize.

To generate docs:

ex_doc "Deordinalize" "VERSION" "_build/dev/lib/deordinalize/ebin" -u "https://github.com/neilberkman/deordinalize"