lib/ordinalize.rb in ordinalize-0.0.2 vs lib/ordinalize.rb in ordinalize-0.0.3

- old
+ new

@@ -11,20 +11,26 @@ # 20, 30, 40, etc. 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",