Sha256: c66af83aabccabdd2b5f44eaf5f2dc455d7359d31a1ad9ebf01ab88cf61905be

Contents?: true

Size: 793 Bytes

Versions: 17

Compression:

Stored size: 793 Bytes

Contents

module Mack
  module Localization # :nodoc:
    module NumberAndCurrencyFormatEngine # :nodoc:
      class Base
        
        def format_currency(num, lang)
          currency = "#{unit}#{format_number(num, lang)}"
          return currency
        end

        def format_number(num, lang)
          num_str = "%01.2f" % num
          parts = num_str.split(".")
          parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
          parts.join separator
        end
        
        protected 
        
        def delimiter
          raise "Unimplemented: delimiter"
        end
        
        def unit
          raise "Unimplemented: unit"
        end
        
        def separator
          raise "Unimplemented: separator"
        end
        
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mack-localization-0.6.0.1 lib/localization/format_engine/nc_engines/base.rb
mack-localization-0.6.1.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.7.0 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.7.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.6.0 lib/localization/format_engine/nc_engines/base.rb
mack-localization-0.6.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.6.1.2 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.7.0.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.7.1.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.0.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.0.101 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.0 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.0.2 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.3 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.3.1 lib/mack-localization/format_engine/nc_engines/base.rb
mack-localization-0.8.2 lib/mack-localization/format_engine/nc_engines/base.rb