Class: LocoStrings::IosFile
- Defined in:
- lib/loco_strings/parsers/ios_file.rb
Overview
IosFile is a class for working with iOS localization strings.
Instance Attribute Summary
Attributes inherited from LocoFile
Instance Method Summary collapse
Methods inherited from LocoFile
#clean, #delete, #initialize, #update, #update_file_path, #value
Constructor Details
This class inherits a constructor from LocoStrings::LocoFile
Instance Method Details
#read ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/loco_strings/parsers/ios_file.rb', line 8 def read clean return @strings unless File.exist?(@file_path) comment = nil file = File.read(@file_path) file.split("\n").each do |line| comment = extract_comment(line) || comment value = extract_string(line, comment) comment = nil if value end @strings end |
#write ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/loco_strings/parsers/ios_file.rb', line 22 def write output = "" @strings.each do |key, value| output += "/* #{value.comment} */\n" if value.comment output += "\"#{key}\" = \"#{value.value}\";\n" end File.write(@file_path, output) end |