Class: LocoStrings::LocoFile

Inherits:
Object
  • Object
show all
Defined in:
lib/loco_strings/parsers/loco_file.rb

Overview

LocoFile is a class for working with localization strings.

Direct Known Subclasses

AndroidFile, IosFile, XCStringsFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ LocoFile

Returns a new instance of LocoFile.



8
9
10
11
# File 'lib/loco_strings/parsers/loco_file.rb', line 8

def initialize(file_path)
  @file_path = file_path
  clean
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



6
7
8
# File 'lib/loco_strings/parsers/loco_file.rb', line 6

def file_path
  @file_path
end

Instance Method Details

#cleanObject



38
39
40
# File 'lib/loco_strings/parsers/loco_file.rb', line 38

def clean
  @strings = {}
end

#delete(key) ⇒ Object



30
31
32
# File 'lib/loco_strings/parsers/loco_file.rb', line 30

def delete(key)
  @strings.delete key
end

#readObject

Raises:



13
14
15
# File 'lib/loco_strings/parsers/loco_file.rb', line 13

def read
  raise Error, "Not implemented"
end

#update(key, value, comment = nil) ⇒ Object



25
26
27
28
# File 'lib/loco_strings/parsers/loco_file.rb', line 25

def update(key, value, comment = nil)
  comment = @strings[key].comment if comment.nil? && @strings.key?(key)
  @strings[key] = LocoString.new key, value, comment
end

#update_file_path(file_path) ⇒ Object



21
22
23
# File 'lib/loco_strings/parsers/loco_file.rb', line 21

def update_file_path(file_path)
  @file_path = file_path
end

#value(key) ⇒ Object



34
35
36
# File 'lib/loco_strings/parsers/loco_file.rb', line 34

def value(key)
  @strings[key]
end

#writeObject

Raises:



17
18
19
# File 'lib/loco_strings/parsers/loco_file.rb', line 17

def write
  raise Error, "Not implemented"
end