Commits

Michael Granger  committed 2082fa7

* Fixed the ':and' setting in EN#numwords. Closes #8.

  • Participants
  • Parent commits baf5b4b

Comments (0)

Files changed (2)

File lib/linguistics/en.rb

 	### 
 	### [<b>:group</b>]
 	###   Controls how many numbers at a time are grouped together. Valid values
-	###   are +0+ (normal grouping), +1+ (single-digit grouping, e.g., "one,
-	###   two, three, four"), +2+ (double-digit grouping, e.g., "twelve,
-	###   thirty-four", or +3+ (triple-digit grouping, e.g., "one twenty-three,
-	###   four").
+	###   are <code>0</code> (normal grouping), <code>1</code> (single-digit 
+	###   grouping, e.g., "one, two, three, four"), <code>2</code> 
+	###   (double-digit grouping, e.g., "twelve, thirty-four", or <code>3</code>
+	###   (triple-digit grouping, e.g., "one twenty-three, four").
 	### [<b>:comma</b>]
-	###   Set the character/s used to separate word groups. Defaults to +", "+.
+	###   Set the character/s used to separate word groups. Defaults to 
+	###   <code>", "</code>.
 	### [<b>:and</b>]
-	###   Set the word and/or characters used where ' and ' (the default) is
-	###   normally used. Setting <tt>:and</tt> to +' '+, for example, will cause
-	###   +2556+ to be returned as "two-thousand, five hundred fifty-six"
-	###   instead of ""two-thousand, five hundred and fifty-six".
+	###   Set the word and/or characters used where <code>' and ' </code>(the 
+	###   default) is normally used. Setting <code>:and</code> to 
+	###   <code>' '</code>, for example, will cause <code>2556</code> to be 
+	###   returned as "two-thousand, five hundred fifty-six" instead of 
+	###   "two-thousand, five hundred and fifty-six".
 	### [<b>:zero</b>]
-	###   Set the word used to represent the numeral +0+ in the result. +'zero'+
-	###   is the default.
+	###   Set the word used to represent the numeral <code>0</code> in the 
+	###   result. <code>'zero'</code> is the default.
 	### [<b>:decimal</b>]
 	###   Set the translation of any decimal points in the number; the default
-	###   is +'point'+.
+	###   is <code>'point'</code>.
 	### [<b>:asArray</b>]
 	###   If set to a true value, the number will be returned as an array of
 	###   word groups instead of a String.
 				# wholenum part with an 'and'. This is to get things like 'three
 				# thousand and three' instead of 'three thousand, three'.
 				if /^\s*(\S+)\s*$/ =~ parts[0].last
-					wholenum += " and #{parts[0].last}"
+					wholenum += config[:and] + parts[0].last
 				else
 					wholenum += config[:comma] + parts[0].last
 				end

File tests/en/inflect.tests.rb

 	begin
 		inDataSection = false
 		methodCounter = 100
-		File::readlines( __FILE__ ).find_all {|line|
+		File::readlines( __FILE__ ).find_all do |line|
 			case line
 			when /^__END_DATA__$/
 				inDataSection = false
 			else
 				inDataSection
 			end
-		}.each {|line|
+		end.each do |line|
 			case line
 			when PluralDataLine
 				singular, plural, altplural, comment = $~.to_a[1,4]
 			else
 				debugMsg "Skipped test data line '#{line.chomp}'"
 			end
-		}
+		end
 	end
 
 	### Overridden initializer: auto-generated test methods have an arity of 1
 	end
 
 
+	def test_numwords_with_an_symboland_should_use_it_to_join_words
+		rval = nil
+		
+		assert_nothing_raised do
+			rval = 2006.en.numwords( :and => ' ' )
+		end
+		
+		assert_equal "two thousand six", rval
+	end
+
+
 	def test_0040_ordinalNumbers
 		printTestHeader "English: Numbers to ordinals"
 		rval = nil