Module: Rubi18n::Formatters::Integer
- Included in:
- Integer
- Defined in:
- lib/rubi18n/formatters.rb
Instance Method Summary collapse
-
#to_ls(locale = Rubi18n::Locale.current) ⇒ Object
Returns the integer in String form, according to the rules of the locale (default currently active).
Instance Method Details
#to_ls(locale = Rubi18n::Locale.current) ⇒ Object
Returns the integer in String form, according to the rules of the locale (default currently active). It will also put real typographic minus.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubi18n/formatters.rb', line 26 def to_ls(locale = Rubi18n::Locale.current) str = self.to_s str[0] = "−" if 0 > self # Real typographic minus group = locale["numbers"]["group_delimiter"] if "indian" == locale["numbers"]["separation"] str.gsub(/(\d)(?=((\d\d\d)(?!\d))|((\d\d)+(\d\d\d)(?!\d)))/) do |match| match + group end else str.gsub(/(\d)(?=(\d\d\d)+(?!\d))/) do |match| match + group end end end |