class TwitterCldr::Localized::LocalizedNumber

Attributes

format[R]
type[R]

Public Class Methods

new(obj, locale, options = {}) click to toggle source
Calls superclass method
# File lib/twitter_cldr/localized/localized_number.rb, line 12
def initialize(obj, locale, options = {})
  @type = options[:type]
  @format = options[:format]
  super
end
types() click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 19
def types
  TwitterCldr::DataReaders::NumberDataReader.types
end

Public Instance Methods

plural_rule() click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 38
def plural_rule
  TwitterCldr::Formatters::Plurals::Rules.rule_for(base_obj, locale)
end
rbnf() click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 55
def rbnf
  @rbnf ||= TwitterCldr::Formatters::Rbnf::RbnfFormatter.new(locale)
end
spellout() click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 42
def spellout
  rbnf.format(
    base_obj, TwitterCldr::Formatters::Rbnf::RbnfFormatter::DEFAULT_SPELLOUT_OPTIONS
  )
end
to_rbnf_s(group_name, rule_set_name) click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 48
def to_rbnf_s(group_name, rule_set_name)
  rbnf.format(base_obj, {
    rule_group: group_name,
    rule_set: rule_set_name
  })
end
to_s(options = {}) click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 30
def to_s(options = {})
  opts = { type: @type, format: @format }.merge(options)

  TwitterCldr::DataReaders::NumberDataReader
    .new(locale, opts)
    .format_number(base_obj, opts)
end
to_unit() click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 59
def to_unit
  TwitterCldr::Shared::Unit.create(base_obj, locale)
end

Private Instance Methods

to_type(target_type) click to toggle source
# File lib/twitter_cldr/localized/localized_number.rb, line 65
def to_type(target_type)
  self.class.new(base_obj, locale, {
    type: target_type,
    format: @format
  })
end