Class: Terrestrial::Cli::AndroidXmlFormatter
- Inherits:
-
Object
- Object
- Terrestrial::Cli::AndroidXmlFormatter
- Defined in:
- lib/terrestrial/cli/android_xml_formatter.rb
Instance Method Summary collapse
- #format_foreign_translation ⇒ Object
-
#initialize(entries) ⇒ AndroidXmlFormatter
constructor
A new instance of AndroidXmlFormatter.
- #print_xml(document) ⇒ Object
Constructor Details
#initialize(entries) ⇒ AndroidXmlFormatter
Returns a new instance of AndroidXmlFormatter.
7 8 9 |
# File 'lib/terrestrial/cli/android_xml_formatter.rb', line 7 def initialize(entries) @entries = entries end |
Instance Method Details
#format_foreign_translation ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/terrestrial/cli/android_xml_formatter.rb', line 11 def format_foreign_translation root = REXML::Element.new("resources") entries.each do |entry| root.add_element("string", { "name" => entry.identifier }).add_text(entry.string) end print_xml(root) end |
#print_xml(document) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/terrestrial/cli/android_xml_formatter.rb', line 23 def print_xml(document) # In which we wrestle with REXML's insanity REXML::Attribute.class_eval( %q^ def to_string %Q[#@expanded_name="#{to_s().gsub(/"/, '"')}"] end ^) formatter = CustomPrinter.new(4) # See editor/printer formatter.compact = true formatter.write(document,"") + "\n" end |