Class: Glossarist::Agent::Iho::Generator
- Inherits:
-
Object
- Object
- Glossarist::Agent::Iho::Generator
- Defined in:
- lib/glossarist/agent/iho/generator.rb
Instance Attribute Summary collapse
-
#language_tables ⇒ Object
Returns the value of attribute language_tables.
-
#simple_concepts ⇒ Object
Returns the value of attribute simple_concepts.
Instance Method Summary collapse
- #build_simple_concepts ⇒ Object
- #collection ⇒ Object
- #convert_to_glossarist ⇒ Object
-
#initialize(cache_dir, output_path) ⇒ Generator
constructor
A new instance of Generator.
- #parse_language_tables ⇒ Object
- #save_to_files ⇒ Object
Constructor Details
#initialize(cache_dir, output_path) ⇒ Generator
Returns a new instance of Generator.
11 12 13 14 15 |
# File 'lib/glossarist/agent/iho/generator.rb', line 11 def initialize(cache_dir, output_path) @cache_dir = cache_dir @output_path = output_path FileUtils.mkdir_p(@output_path) end |
Instance Attribute Details
#language_tables ⇒ Object
Returns the value of attribute language_tables.
9 10 11 |
# File 'lib/glossarist/agent/iho/generator.rb', line 9 def language_tables @language_tables end |
#simple_concepts ⇒ Object
Returns the value of attribute simple_concepts.
9 10 11 |
# File 'lib/glossarist/agent/iho/generator.rb', line 9 def simple_concepts @simple_concepts end |
Instance Method Details
#build_simple_concepts ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/glossarist/agent/iho/generator.rb', line 44 def build_simple_concepts return @simple_concepts if @simple_concepts @simple_concepts = {} build_english_concepts build_other_language_concepts @simple_concepts end |
#collection ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/glossarist/agent/iho/generator.rb', line 17 def collection return @collection if @collection parse_language_tables build_simple_concepts convert_to_glossarist @collection end |
#convert_to_glossarist ⇒ Object
53 54 55 56 |
# File 'lib/glossarist/agent/iho/generator.rb', line 53 def convert_to_glossarist @collection = ::Glossarist::ManagedConceptCollection.new @collection.managed_concepts = create_managed_concepts end |
#parse_language_tables ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/glossarist/agent/iho/generator.rb', line 27 def parse_language_tables return @language_tables if @language_tables @language_tables = {} Dir.glob(File.join(@cache_dir, "*.csv")).map do |file| lang_code = Downloader.lang_code_by_filename(File.basename(file)) table = BilingualTable.new(file_path: file, lang_code: lang_code).tap do |table| table.process end @language_tables[lang_code] = table end @language_tables end |
#save_to_files ⇒ Object
58 59 60 61 |
# File 'lib/glossarist/agent/iho/generator.rb', line 58 def save_to_files collection.save_to_files(@output_path) puts "Concepts generated and saved to #{@output_path}" end |