Class: Bruno::AndroidFile
- Defined in:
- lib/bruno/android_file.rb
Instance Attribute Summary
Attributes inherited from I18nFile
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from I18nFile
#initialize, is_android?, is_ios?
Constructor Details
This class inherits a constructor from Bruno::I18nFile
Class Method Details
.read(content) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/bruno/android_file.rb', line 4 def self.read(content) strings = [] xml = Nokogiri::XML(content) xml.root.xpath('string').each do |string| strings << {:key => string.attribute('name').value, :value => string.content} end strings end |
Instance Method Details
#write(path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bruno/android_file.rb', line 14 def write(path) file = File.new(path, 'w+') builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.resources { @strings.each do |string| xml.string({:name => string[:key]}) { xml.text string[:value] } end } end file.write(builder.to_xml) file.close end |