Class: Moirai::TranslationFileHandler

Inherits:
Object
  • Object
show all
Defined in:
app/models/moirai/translation_file_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTranslationFileHandler

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_hashesObject (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_pathsObject (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