Class: CLDR::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/cldr/object.rb

Constant Summary collapse

@@data_cache =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Object

Create a new CLDR::Object object. This object creates all of the instances of resource classes.

  • opts: options

    * :locale: the Locale::Object
    * :fallback: the alternative Locale::Object when locale is not found.
    
  • Returns: a newly created Locale::Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cldr/object.rb', line 27

def initialize(opts = {})
  locale = opts[:locale] ? opts[:locale] : Locale.get
  fallback = opts[:fallback] ? opts[:fallback] : Locale::Tag::Cldr.new("en")

  data = @@data_cache[locale]
  unless data
    @core = Core.new(locale, fallback)
    @calendar = Calendar.new(locale, fallback)
    @timezone = TimeZone.new(locale, fallback)
    @number = Number.new(locale, fallback)
    @currency = Currency.new(locale, fallback)
    @supplemental = Supplemental.new(locale, fallback)
    @@data_cache[locale] = [@core, @calendar, @timezone, @number, @currency, @supplemental]
  else
    @core, @calendar, @timezone, @number, @currency, @supplemental = data
  end
end

Instance Attribute Details

#calendarObject (readonly)

Returns the value of attribute calendar.



20
21
22
# File 'lib/cldr/object.rb', line 20

def calendar
  @calendar
end

#coreObject (readonly)

Returns the value of attribute core.



20
21
22
# File 'lib/cldr/object.rb', line 20

def core
  @core
end

#currencyObject (readonly)

Returns the value of attribute currency.



20
21
22
# File 'lib/cldr/object.rb', line 20

def currency
  @currency
end

#numberObject (readonly)

Returns the value of attribute number.



20
21
22
# File 'lib/cldr/object.rb', line 20

def number
  @number
end

#supplementalObject (readonly)

Returns the value of attribute supplemental.



20
21
22
# File 'lib/cldr/object.rb', line 20

def supplemental
  @supplemental
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



20
21
22
# File 'lib/cldr/object.rb', line 20

def timezone
  @timezone
end