Class: LocoStrings::XCStringsDecoder
- Inherits:
-
Object
- Object
- LocoStrings::XCStringsDecoder
- Defined in:
- lib/loco_strings/decoders/xcstrings_decoder.rb
Overview
The XCStringsDecoder class is responsible for decoding the XCStrings file format.
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#strings ⇒ Object
readonly
Returns the value of attribute strings.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
- #decode ⇒ Object
-
#initialize(file_path) ⇒ XCStringsDecoder
constructor
A new instance of XCStringsDecoder.
Constructor Details
#initialize(file_path) ⇒ XCStringsDecoder
Returns a new instance of XCStringsDecoder.
10 11 12 13 14 15 16 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 10 def initialize(file_path) @file_path = file_path @strings = {} @translations = {} @languages = [] @language = nil end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
8 9 10 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 8 def language @language end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
8 9 10 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 8 def languages @languages end |
#strings ⇒ Object (readonly)
Returns the value of attribute strings.
8 9 10 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 8 def strings @strings end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
8 9 10 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 8 def translations @translations end |
Instance Method Details
#decode ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/loco_strings/decoders/xcstrings_decoder.rb', line 18 def decode return @strings unless File.exist?(@file_path) file = File.read(@file_path) json = JSON.parse(file) extract_languages(json) @language = json["sourceLanguage"] decode_strings(json) @strings end |