Class: TwitterCldr::Localized::LocalizedObject

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/localized/localized_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, locale, options = {}) ⇒ LocalizedObject

Returns a new instance of LocalizedObject.



13
14
15
16
17
18
19
20
# File 'lib/twitter_cldr/localized/localized_object.rb', line 13

def initialize(obj, locale, options = {})
  @base_obj = obj
  @locale = TwitterCldr.convert_locale(locale)
  @locale = TwitterCldr::DEFAULT_LOCALE unless TwitterCldr.supported_locale?(@locale)

  options = options.dup
  options[:locale] = @locale
end

Instance Attribute Details

#base_objObject (readonly)

Returns the value of attribute base_obj.



11
12
13
# File 'lib/twitter_cldr/localized/localized_object.rb', line 11

def base_obj
  @base_obj
end

#formatterObject (readonly)

Returns the value of attribute formatter.



11
12
13
# File 'lib/twitter_cldr/localized/localized_object.rb', line 11

def formatter
  @formatter
end

#localeObject (readonly)

Returns the value of attribute locale.



11
12
13
# File 'lib/twitter_cldr/localized/localized_object.rb', line 11

def locale
  @locale
end

Class Method Details

.localize(klass) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/twitter_cldr/localized/localized_object.rb', line 22

def self.localize(klass)
  klass.class_eval <<-LOCALIZE, __FILE__, __LINE__ + 1
    def localize(locale = TwitterCldr.locale, options = {})
      #{self}.new(self, locale, options)
    end
  LOCALIZE
end