0.0
No commit activity in last 3 years
No release in over 3 years
Small gem to 'deordinalize' strings into the integers they reference. Intended to be hella useful in cucumber steps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

deordinalize

A small gem to 'deordinalize' strings into the integers they reference.

Installation:

gem install deordinalize and require it. String now has the deordinalize method.

Usage:

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

We can deordinalize numeric ordinals:

'1st'.deordinalize   # => 1
'11th'.deordinalize  # => 11
'99th'.deordinalize  # => 99

Or we can deordinalize more verbose ordinals:

'first'.deordinalize         # => 1
'eleventh'.deordinalize      # => 11
'ninety-ninth'.deordinalize  # => 99

Add a bang to the method to get the zero-based index of your ordinal:

'first'.deordinalize!         # => 0
'eleventh'.deordinalize!      # => 10
'ninety-ninth'.deordinalize!  # => 98

This is meant to be hella useful in cucumber steps, like:

When /^I click on the (.+) item in the list$/ do |ordinal|
	page.find( :xpath, "//li[#{ordinal.deordinalize!}]" ).click
end