class Terrestrial::Cli::AndroidXmlFormatter
Public Class Methods
new(entries)
click to toggle source
# File lib/terrestrial/cli/android_xml_formatter.rb, line 7 def initialize(entries) @entries = entries end
Public Instance Methods
format_foreign_translation()
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
entries()
click to toggle source
# File lib/terrestrial/cli/android_xml_formatter.rb, line 38 def entries @entries end