diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-10 17:30:38 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-10 17:30:38 +0000 |
commit | 5cd815addfe88e7a1f886b9722963d24343db4ed (patch) | |
tree | 10de4bc5ac1fb98d61ae29e93d4ab761cc8b3be6 /actionpack | |
parent | 2daf2c846d5e6affde515f3f29e415add173916d (diff) | |
download | rails-5cd815addfe88e7a1f886b9722963d24343db4ed.tar.gz rails-5cd815addfe88e7a1f886b9722963d24343db4ed.tar.bz2 rails-5cd815addfe88e7a1f886b9722963d24343db4ed.zip |
Fixed spelling of delimiter #1058
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1134 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/number_helper.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index f893da9b9d..05103e09ff 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -6,21 +6,21 @@ module ActionView # Formats a +number+ into a US phone number string. The +options+ can be hash used to customize the format of the output. # The area code can be surrounded by parenthesis by setting +:area_code+ to true; default is false - # The delimeter can be set using +:delimter+; default is "-" + # The delimiter can be set using +:delimiter+; default is "-" # Examples: # number_to_phone(1235551234) => 123-555-1234 # number_to_phone(1235551234, {:area_code => true}) => (123) 555-1234 - # number_to_phone(1235551234, {:delimter => " "}) => 123 555 1234 + # number_to_phone(1235551234, {:delimiter => " "}) => 123 555 1234 def number_to_phone(number, options = {}) options = options.stringify_keys area_code = options.delete("area_code") { false } - delimeter = options.delete("delimeter") { "-" } + delimiter = options.delete("delimiter") { "-" } begin str = number.to_s if area_code == true - str.gsub!(/([0-9]{3})([0-9]{3})([0-9]{4})/,"(\\1) \\2#{delimeter}\\3") + str.gsub!(/([0-9]{3})([0-9]{3})([0-9]{4})/,"(\\1) \\2#{delimiter}\\3") else - str.gsub!(/([0-9]{3})([0-9]{3})([0-9]{4})/,"\\1#{delimeter}\\2#{delimeter}\\3") + str.gsub!(/([0-9]{3})([0-9]{3})([0-9]{4})/,"\\1#{delimiter}\\2#{delimiter}\\3") end rescue number @@ -31,17 +31,17 @@ module ActionView # The +number+ can contain a level of precision using the +precision+ key; default is 2 # The currency type can be set using the +unit+ key; default is "$" # The unit separator can be set using the +separator+ key; default is "." - # The delimter can be set using the +delimeter+ key; default is "," + # The delimiter can be set using the +delimiter+ key; default is "," # Examples: # number_to_currency(1234567890.50) => $1,234,567,890.50 # number_to_currency(1234567890.506) => $1,234,567,890.51 - # number_to_currency(1234567890.50, {:unit => "£", :separator => ",", :delimeter => ""}) => £123456789,50 + # number_to_currency(1234567890.50, {:unit => "£", :separator => ",", :delimiter => ""}) => £123456789,50 def number_to_currency(number, options = {}) options = options.stringify_keys - precision, unit, separator, delimeter = options.delete("precision") { 2 }, options.delete("unit") { "$" }, options.delete("separator") { "." }, options.delete("delimeter") { "," } + precision, unit, separator, delimiter = options.delete("precision") { 2 }, options.delete("unit") { "$" }, options.delete("separator") { "." }, options.delete("delimiter") { "," } begin parts = number_with_precision(number, precision).split('.') - unit + number_with_delimeter(parts[0]) + separator + parts[1].to_s + unit + number_with_delimiter(parts[0]) + separator + parts[1].to_s rescue number end @@ -70,11 +70,11 @@ module ActionView end end - # Formats a +number+ with a +delimeter+. + # Formats a +number+ with a +delimiter+. # Example: - # number_with_delimeter(12345678) => 1,235,678 - def number_with_delimeter(number, delimeter=",") - number.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimeter}") + # number_with_delimiter(12345678) => 1,235,678 + def number_with_delimiter(number, delimiter=",") + number.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}") end # Formats a +number+ with a level of +precision+. @@ -85,4 +85,4 @@ module ActionView end end end -end
\ No newline at end of file +end |