Class: Abroad::Serializers::Xml::AndroidSerializer
- Inherits:
-
XmlSerializer
- Object
- Serializer
- XmlSerializer
- Abroad::Serializers::Xml::AndroidSerializer
- Defined in:
- lib/abroad/serializers/xml/android_serializer.rb
Constant Summary collapse
- PLURAL_FORMS =
%w( zero one two few many other )
Constants inherited from Serializer
Instance Attribute Summary collapse
-
#arrays ⇒ Object
readonly
Returns the value of attribute arrays.
-
#plurals ⇒ Object
readonly
Returns the value of attribute plurals.
Attributes inherited from XmlSerializer
Attributes inherited from Serializer
Instance Method Summary collapse
- #after_initialize ⇒ Object
- #flush ⇒ Object
- #write_key_value(key, value) ⇒ Object
- #write_raw(text) ⇒ Object
Methods inherited from XmlSerializer
Methods inherited from Serializer
#close, #encoding, from_stream, #initialize, open
Constructor Details
This class inherits a constructor from Abroad::Serializers::Xml::XmlSerializer
Instance Attribute Details
#arrays ⇒ Object (readonly)
Returns the value of attribute arrays.
13 14 15 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 13 def arrays @arrays end |
#plurals ⇒ Object (readonly)
Returns the value of attribute plurals.
13 14 15 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 13 def plurals @plurals end |
Instance Method Details
#after_initialize ⇒ Object
15 16 17 18 19 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 15 def after_initialize writer.open_tag('resources') @plurals = Hash.new { |hash, key| hash[key] = {} } @arrays = Hash.new { |hash, key| hash[key] = {} } end |
#flush ⇒ Object
38 39 40 41 42 43 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 38 def flush write_recorded_plurals write_recorded_arrays writer.flush stream.flush end |
#write_key_value(key, value) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 25 def write_key_value(key, value) key_parts = split_key(key) case detect_string_type(key_parts) when :plural record_plural(key_parts, value) when :array_element record_array_element(key_parts, value) else write_string(key, value) end end |
#write_raw(text) ⇒ Object
21 22 23 |
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 21 def write_raw(text) stream.write(text) end |