Permalink
Browse files

Rename split to split_dashes to make room for split_spaces so numbers…

… such as 1005 work. [Remear]
  • Loading branch information...
1 parent 50076c9 commit c8af7a1a10831fccf2bd6eff968312d405fe3c30 @radar committed Dec 26, 2009
Showing with 12 additions and 5 deletions.
  1. +10 −4 lib/ordinalize.rb
  2. +1 −1 ordinalize.gemspec
  3. +1 −0 spec/ordinalize_spec.rb
View
@@ -13,19 +13,25 @@ def ordinalize
humanized.gsub!(/ty$/, 'tieth')
output = conversions[humanized] if conversions[humanized]
- output ||= split if split != ""
+ output ||= split_dashes if split_dashes != ""
+ output ||= split_spaces if split_spaces != ""
output ||= humanized
end
alias_method :ordinalise, :ordinalize
- def split
- humanized = self.humanize
- parts = humanized.split("-")
+ def split_dashes
+ parts = humanize.split("-")
parts[-1] = conversions[parts.last]
parts.join("-")
end
+ def split_spaces
+ parts = humanize.split(" ")
+ parts[-1] = conversions[parts.last]
+ parts.join(" ")
+ end
+
def conversions
{
"one" => "first",
View
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{ordinalize}
- s.version = "0.0.1"
+ s.version = "0.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ryan Bigg"]
View
@@ -31,6 +31,7 @@
[27, "twenty-seventh"],
[28, "twenty-eighth"],
[29, "twenty-ninth"],
+ [1005, "one thousand and fifth"],
[1024, "one thousand and twenty-fourth"]
].each do |num, expected|
it "#{num} should be #{expected}" do

0 comments on commit c8af7a1

Please sign in to comment.