Class: TwitterCldr::Localized::LocalizedNumber
Instance Attribute Summary collapse
#base_obj, #formatter, #locale
Class Method Summary
collapse
Instance Method Summary
collapse
localize
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, options = {})
@type = options[:type]
@format = options[:format]
super
end
|
Instance Attribute Details
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
Returns the value of attribute type.
10
11
12
|
# File 'lib/twitter_cldr/localized/localized_number.rb', line 10
def type
@type
end
|
Instance Method Details
#to_rbnf_s(group_name, rule_set_name) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/twitter_cldr/localized/localized_number.rb', line 60
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
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/twitter_cldr/localized/localized_number.rb', line 30
def to_s(options = {})
data_reader = TwitterCldr::DataReaders::NumberDataReader.new(locale, {
:type => @type,
:format => @format
})
pattern = data_reader.pattern(base_obj)
if pattern == 0
base_obj.to_s
else
data_reader.formatter.format(
data_reader.tokenizer.tokenize(pattern),
base_obj,
options.merge(:type => @type)
)
end
end
|