Class: Moirai::TranslationFileHandler
- Inherits:
-
Object
- Object
- Moirai::TranslationFileHandler
- Defined in:
- app/models/moirai/translation_file_handler.rb
Instance Attribute Summary collapse
-
#file_hashes ⇒ Object
readonly
Returns the value of attribute file_hashes.
-
#file_paths ⇒ Object
readonly
Returns the value of attribute file_paths.
Instance Method Summary collapse
- #get_first_key(file_path) ⇒ Object
-
#initialize ⇒ TranslationFileHandler
constructor
A new instance of TranslationFileHandler.
- #parse_file(path) ⇒ Object
Constructor Details
#initialize ⇒ TranslationFileHandler
Returns a new instance of TranslationFileHandler.
7 8 9 10 |
# File 'app/models/moirai/translation_file_handler.rb', line 7 def initialize load_file_paths generate_file_hashes end |
Instance Attribute Details
#file_hashes ⇒ Object (readonly)
Returns the value of attribute file_hashes.
5 6 7 |
# File 'app/models/moirai/translation_file_handler.rb', line 5 def file_hashes @file_hashes end |
#file_paths ⇒ Object (readonly)
Returns the value of attribute file_paths.
5 6 7 |
# File 'app/models/moirai/translation_file_handler.rb', line 5 def file_paths @file_paths end |
Instance Method Details
#get_first_key(file_path) ⇒ Object
18 19 20 21 |
# File 'app/models/moirai/translation_file_handler.rb', line 18 def get_first_key(file_path) yaml_content = YAML.load_file(file_path) yaml_content.keys.first end |
#parse_file(path) ⇒ Object
12 13 14 15 16 |
# File 'app/models/moirai/translation_file_handler.rb', line 12 def parse_file(path) yaml_content = YAML.load_file(path) root_key = yaml_content.keys.first flatten_hash(yaml_content[root_key]) end |