Sha256: 66dd689225a38b317980302b4598020827980e0e010510968774c6082976b307

Contents?: true

Size: 713 Bytes

Versions: 4

Compression:

Stored size: 713 Bytes

Contents

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

class TwitterCldr.NumberingSystems
  @for_name : (name) ->
    @system_cache[name] || (
      if (system = @resource[name])?
        if system["type"] isnt "numeric"
          throw "#{system[type]} numbering systems not supported."
        else
          new @(system["name"], system["digits"])
      else
        null
    )

  @system_cache = {}
  @resource = `{{{resource}}}`

  constructor : (@name, digits) ->
    @digits = @split_digits(digits)

  split_digits : (str) ->
    str.split('')

  transliterate : (number) ->
    (number + "").replace(/\d/g, ((digit, position) ->
        @digits[parseInt(digit)]
      ).bind(@)
    )

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter_cldr_js-3.3.0 lib/twitter_cldr/js/mustache/implementation/shared/numbering_systems.coffee
twitter_cldr_js-3.2.0 lib/twitter_cldr/js/mustache/implementation/shared/numbering_systems.coffee
twitter_cldr_js-3.1.1 lib/twitter_cldr/js/mustache/implementation/shared/numbering_systems.coffee
twitter_cldr_js-3.1.0 lib/twitter_cldr/js/mustache/implementation/shared/numbering_systems.coffee