Class: Sources::CLDR::Subdivision
- Inherits:
-
Object
- Object
- Sources::CLDR::Subdivision
- Defined in:
- lib/countries/sources/cldr/subdivision.rb
Overview
Auxiliary Subdivision class to support loading Unicode CLDR data to update local files
Instance Attribute Summary collapse
-
#language_code ⇒ Object
readonly
Returns the value of attribute language_code.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #code ⇒ Object
- #country_code ⇒ Object
-
#initialize(language_code:, xml:) ⇒ Subdivision
constructor
A new instance of Subdivision.
- #text ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(language_code:, xml:) ⇒ Subdivision
Returns a new instance of Subdivision.
9 10 11 12 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 9 def initialize(language_code:, xml:) @language_code = language_code @xml = xml end |
Instance Attribute Details
#language_code ⇒ Object (readonly)
Returns the value of attribute language_code.
7 8 9 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 7 def language_code @language_code end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
7 8 9 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 7 def xml @xml end |
Instance Method Details
#code ⇒ Object
22 23 24 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 22 def code type[2..].upcase end |
#country_code ⇒ Object
18 19 20 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 18 def country_code type[0..1].upcase end |
#text ⇒ Object
14 15 16 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 14 def text xml.text end |
#to_h ⇒ Object
30 31 32 33 34 35 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 30 def to_h data = {} data['translations'] ||= {} data['translations'][language_code] = text data end |
#type ⇒ Object
26 27 28 |
# File 'lib/countries/sources/cldr/subdivision.rb', line 26 def type xml.attributes['type'].value.delete('-') end |