Class: TwitterCldr::Localized::LocalizedNumber
- Inherits:
-
LocalizedObject
- Object
- LocalizedObject
- TwitterCldr::Localized::LocalizedNumber
- Defined in:
- lib/twitter_cldr/localized/localized_number.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from LocalizedObject
#base_obj, #formatter, #locale
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(obj, locale, options = {}) ⇒ LocalizedNumber
constructor
A new instance of LocalizedNumber.
- #plural_rule ⇒ Object
- #rbnf ⇒ Object
- #spellout ⇒ Object
- #to_rbnf_s(group_name, rule_set_name) ⇒ Object
- #to_s(options = {}) ⇒ Object
- #to_unit ⇒ Object
Methods inherited from LocalizedObject
Constructor Details
#initialize(obj, locale, options = {}) ⇒ LocalizedNumber
Returns a new instance of LocalizedNumber.
12 13 14 15 16 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 12 def initialize(obj, locale, = {}) @type = [:type] @format = [:format] super end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
10 11 12 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 10 def format @format end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 10 def type @type end |
Class Method Details
.types ⇒ Object
19 20 21 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 19 def types TwitterCldr::DataReaders::NumberDataReader.types end |
Instance Method Details
#plural_rule ⇒ Object
38 39 40 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 38 def plural_rule TwitterCldr::Formatters::Plurals::Rules.rule_for(base_obj, locale) end |
#rbnf ⇒ Object
55 56 57 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 55 def rbnf @rbnf ||= TwitterCldr::Formatters::Rbnf::RbnfFormatter.new(locale) end |
#spellout ⇒ Object
42 43 44 45 46 |
# 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) ⇒ Object
48 49 50 51 52 53 |
# 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 = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 30 def to_s( = {}) opts = { type: @type, format: @format }.merge() TwitterCldr::DataReaders::NumberDataReader .new(locale, opts) .format_number(base_obj, opts) end |
#to_unit ⇒ Object
59 60 61 |
# File 'lib/twitter_cldr/localized/localized_number.rb', line 59 def to_unit TwitterCldr::Shared::Unit.create(base_obj, locale) end |