Class: TwitterCldr::Formatters::ListFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/twitter_cldr/formatters/list_formatter.rb

Instance Attribute Summary collapse

Attributes inherited from Formatter

#data_reader

Instance Method Summary collapse

Constructor Details

#initialize(locale = TwitterCldr.locale) ⇒ ListFormatter

Returns a new instance of ListFormatter.



12
13
14
# File 'lib/twitter_cldr/formatters/list_formatter.rb', line 12

def initialize(locale = TwitterCldr.locale)
  @locale = TwitterCldr.convert_locale(locale)
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



10
11
12
# File 'lib/twitter_cldr/formatters/list_formatter.rb', line 10

def locale
  @locale
end

Instance Method Details

#format(list, type = :default) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/twitter_cldr/formatters/list_formatter.rb', line 16

def format(list, type = :default)
  if res = resource_for_type(type)
    if res.include?(list.size)
      compose(res[list.size], list)
    else
      compose_list(list, res)
    end
  end
end

#typesObject



26
27
28
# File 'lib/twitter_cldr/formatters/list_formatter.rb', line 26

def types
  resource.keys
end