Skip to content

Elixir package to convert strings representing ordinal numbers to the integers they reference

License

Notifications You must be signed in to change notification settings

neilberkman/deordinalize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"

About

Elixir package to convert strings representing ordinal numbers to the integers they reference

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages