Class: TwitterCldr::Localized::LocalizedString
Instance Attribute Summary
#base_obj, #formatter, #locale
Instance Method Summary
collapse
#initialize, localize
Instance Method Details
#%(args) ⇒ Object
Uses wrapped string object as a format specification and returns the result of applying it to args
(see TwitterCldr::Utils.interpolate
method for interpolation syntax).
If args
is a Hash than pluralization is performed before interpolation (see PluralFormatter
class for pluralization specification).
18
19
20
21
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 18
def %(args)
pluralized = args.is_a?(Hash) ? @formatter.format(@base_obj, args) : @base_obj
TwitterCldr::Utils.interpolate(pluralized, args)
end
|
#bytesize ⇒ Object
59
60
61
62
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 59
def bytesize
@base_obj.respond_to?(:bytesize) ? @base_obj.bytesize : @base_obj.size
end
|
#each_char ⇒ Object
Also known as:
each
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 72
def each_char
if block_given?
code_points.each do |code_point|
yield TwitterCldr::Utils::CodePoints.to_char(code_point)
end
@base_obj
else
code_points.map { |code_point| TwitterCldr::Utils::CodePoints.to_char(code_point) }.to_enum
end
end
|
#normalize(options = {}) ⇒ Object
27
28
29
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 27
def normalize(options = {})
TwitterCldr::Normalization.normalize(@base_obj, options).localize(@locale)
end
|
#size ⇒ Object
Also known as:
length
53
54
55
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 53
def size
code_points.size
end
|
#to_bidi(options = {}) ⇒ Object
89
90
91
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 89
def to_bidi(options = {})
TwitterCldr::Shared::Bidi.from_string(@base_obj, options)
end
|
#to_f(options = {}) ⇒ Object
#to_i(options = {}) ⇒ Object
39
40
41
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 39
def to_i(options = {})
to_f(options).to_i
end
|
#to_reordered_s(options = {}) ⇒ Object
93
94
95
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 93
def to_reordered_s(options = {})
to_bidi(options).reorder_visually!.to_s
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 35
def to_s
@base_obj.dup
end
|
#to_yaml(options = {}) ⇒ Object
85
86
87
|
# File 'lib/twitter_cldr/localized/localized_string.rb', line 85
def to_yaml(options = {})
TwitterCldr::Utils::YAML.dump(@base_obj, options)
end
|