lib/csl/locale/ordinalize.rb in csl-1.0.0.pre10 vs lib/csl/locale/ordinalize.rb in csl-1.0.0.pre11

- old
+ new

@@ -35,11 +35,13 @@ # @return [String] the ordinal for the passed-in number def ordinalize(number, options = {}) raise ArgumentError, "unable to ordinalize #{number}; integer expected" unless number.respond_to?(:to_i) - number, query = number.to_i, ordinalize_query_for(options) + number = number.to_i + + key = query[:name] # Try to match long-ordinals first if key.start_with?('l') @@ -95,22 +97,27 @@ end end private - # @return [Hash] a valid ordinalize query; the name attribute is a format string - def ordinalize_query_for(options) + def normalize_gender_options(options) + gender = (options[:'gender-form'] || options[:gender]).to_s + unless gender.empty? || gender =~ /^n/i + q[:'gender-form'] = (gender =~ /^m/i) ? 'masculine' : 'feminine' + end + end + + def normalize_plural_options(options) + end + + def ordinalize_options_for(options) q = { :name => 'ordinal-%02d' } unless options.nil? if options.key?(:form) && options[:form].to_s =~ /^long(-ordinal)?$/i q[:name] = 'long-ordinal-%02d' end - gender = (options[:'gender-form'] || options[:gender]).to_s - unless gender.empty? || gender =~ /^n/i - q[:'gender-form'] = (gender =~ /^m/i) ? 'masculine' : 'feminine' - end end q end