Class: TwitterCldr::Formatters::Formatter
- Inherits:
-
Object
- Object
- TwitterCldr::Formatters::Formatter
- Defined in:
- lib/twitter_cldr/formatters/formatter.rb
Direct Known Subclasses
DateTimeFormatter, ListFormatter, NumberFormatter, TimespanFormatter
Instance Attribute Summary collapse
-
#data_reader ⇒ Object
readonly
Returns the value of attribute data_reader.
Instance Method Summary collapse
- #format(tokens, obj, options = {}) ⇒ Object
-
#initialize(data_reader) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(data_reader) ⇒ Formatter
Returns a new instance of Formatter.
12 13 14 |
# File 'lib/twitter_cldr/formatters/formatter.rb', line 12 def initialize(data_reader) @data_reader = data_reader end |
Instance Attribute Details
#data_reader ⇒ Object (readonly)
Returns the value of attribute data_reader.
10 11 12 |
# File 'lib/twitter_cldr/formatters/formatter.rb', line 10 def data_reader @data_reader end |
Instance Method Details
#format(tokens, obj, options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/twitter_cldr/formatters/formatter.rb', line 16 def format(tokens, obj, = {}) tokens.each_with_index.inject("") do |ret, (token, index)| method_sym = :"format_#{token.type}" ret << send(method_sym, token, index, obj, ) end end |