Class: Abroad::Serializers::Xml::AndroidSerializer

Inherits:
XmlSerializer show all
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

Serializer::DEFAULT_ENCODING

Instance Attribute Summary collapse

Attributes inherited from XmlSerializer

#writer

Attributes inherited from Serializer

#locale, #options, #stream

Instance Method Summary collapse

Methods inherited from XmlSerializer

#initialize

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

#arraysObject (readonly)

Returns the value of attribute arrays.



13
14
15
# File 'lib/abroad/serializers/xml/android_serializer.rb', line 13

def arrays
  @arrays
end

#pluralsObject (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_initializeObject



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

#flushObject



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