Skip to content

Instantly share code, notes, and snippets.

@camertron
Created January 6, 2014 22:28
Show Gist options
  • Save camertron/8290969 to your computer and use it in GitHub Desktop.
Save camertron/8290969 to your computer and use it in GitHub Desktop.
RBNF example with twitter-cldr-rb, v3.0 branch
require 'twitter_cldr'
num = 1234.localize(:en) # locale is optional, defaults to :en
# "one thousand two hundred thirty-four"
num.spellout
# ["SpelloutRules", "OrdinalRules"]
num.rbnf.group_names
# ["spellout-numbering-year", "spellout-numbering-verbose", "spellout-ordinal" ... ]
num.rbnf.rule_set_names_for_group("SpelloutRules")
# "one thousand two hundred thirty-fourth"
num.to_rbnf_s("SpelloutRules", "spellout-ordinal")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment