Class: Chivy::TreeManager
- Inherits:
-
Object
- Object
- Chivy::TreeManager
- Defined in:
- lib/chivy/tree_manager.rb
Constant Summary collapse
- TRANSLATION_YML_REGEX =
/(\S*)\.(\S*)(.yml)/
Instance Attribute Summary collapse
-
#base_locales ⇒ Object
Returns the value of attribute base_locales.
-
#base_names ⇒ Object
Returns the value of attribute base_names.
-
#files ⇒ Object
Returns the value of attribute files.
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#loaded_files ⇒ Object
Returns the value of attribute loaded_files.
Class Method Summary collapse
-
.load(folder, files) ⇒ Object
returns files successfully loaded.
Instance Method Summary collapse
- #each_base_name(&block) ⇒ Object
- #fill ⇒ Object
-
#initialize(folder, files) ⇒ TreeManager
constructor
A new instance of TreeManager.
Constructor Details
#initialize(folder, files) ⇒ TreeManager
Returns a new instance of TreeManager.
10 11 12 13 14 15 16 |
# File 'lib/chivy/tree_manager.rb', line 10 def initialize(folder, files) @files = files @folder = folder @base_names = {} @base_locales = {} @loaded_files = [] end |
Instance Attribute Details
#base_locales ⇒ Object
Returns the value of attribute base_locales.
7 8 9 |
# File 'lib/chivy/tree_manager.rb', line 7 def base_locales @base_locales end |
#base_names ⇒ Object
Returns the value of attribute base_names.
7 8 9 |
# File 'lib/chivy/tree_manager.rb', line 7 def base_names @base_names end |
#files ⇒ Object
Returns the value of attribute files.
7 8 9 |
# File 'lib/chivy/tree_manager.rb', line 7 def files @files end |
#folder ⇒ Object
Returns the value of attribute folder.
7 8 9 |
# File 'lib/chivy/tree_manager.rb', line 7 def folder @folder end |
#loaded_files ⇒ Object
Returns the value of attribute loaded_files.
7 8 9 |
# File 'lib/chivy/tree_manager.rb', line 7 def loaded_files @loaded_files end |
Class Method Details
.load(folder, files) ⇒ Object
returns files successfully loaded
19 20 21 22 23 |
# File 'lib/chivy/tree_manager.rb', line 19 def self.load(folder, files) tree_manager = TreeManager.new(folder, files) tree_manager.fill tree_manager end |
Instance Method Details
#each_base_name(&block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/chivy/tree_manager.rb', line 25 def each_base_name &block base_names.each do |name, trees| trees.each do |tree| block.call(tree) end end end |
#fill ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chivy/tree_manager.rb', line 34 def fill files.each do |filename| if filename.match TRANSLATION_YML_REGEX tree = Chivy::Tree.new filename tree.load File.join(folder, filename) loaded_files << filename add_base_name(tree) add_base_locale(tree) end end end |