1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

implicitly return nil if there is no number

This commit is contained in:
Aaron Patterson 2010-10-18 10:01:26 -07:00
parent 98d3c41cfb
commit a0a5a2a275

View file

@ -102,7 +102,7 @@ module ActionView
# number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u") # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u")
# # => 1234567890,50 £ # # => 1234567890,50 £
def number_to_currency(number, options = {}) def number_to_currency(number, options = {})
return nil if number.nil? return unless number
options.symbolize_keys! options.symbolize_keys!
@ -147,7 +147,7 @@ module ActionView
# number_to_percentage(302.24398923423, :precision => 5) # => 302.24399% # number_to_percentage(302.24398923423, :precision => 5) # => 302.24399%
# number_to_percentage(1000, :locale => :fr) # => 1 000,000% # number_to_percentage(1000, :locale => :fr) # => 1 000,000%
def number_to_percentage(number, options = {}) def number_to_percentage(number, options = {})
return nil if number.nil? return unless number
options.symbolize_keys! options.symbolize_keys!