Class: Bruno::IOSFile

Inherits:
I18nFile show all
Defined in:
lib/bruno/ios_file.rb

Instance Attribute Summary

Attributes inherited from I18nFile

#strings

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



2
3
4
5
6
7
8
9
10
# File 'lib/bruno/ios_file.rb', line 2

def self.read(content)
  strings = []
  content.each_line do |line|
    match_key = line.match(/\"([^\"]+)\"/)
    match_value = line.match(/= \"([^\"]+)\";/) #"
    strings << {:key => match_key[1], :value => match_value[1]}
  end
  strings
end

Instance Method Details

#write(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bruno/ios_file.rb', line 12

def write(path)
  file = File.new(path,'w+')

  @strings.each_with_index do |string, index|
    file.write(compose_line(string[:key], string[:value]))

    if index != @strings.length - 1
      file.write("\n")
    end
  end
  file.close
end