Class: Glossarist::Agent::Iho::BilingualTable

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/agent/iho/bilingual_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path:, lang_code:) ⇒ BilingualTable

Returns a new instance of BilingualTable.



31
32
33
34
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 31

def initialize(file_path:, lang_code:)
  @file_path = file_path
  @lang_code = lang_code
end

Instance Attribute Details

#concepts_engObject

Returns the value of attribute concepts_eng.



29
30
31
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 29

def concepts_eng
  @concepts_eng
end

#concepts_otherObject

Returns the value of attribute concepts_other.



29
30
31
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 29

def concepts_other
  @concepts_other
end

#file_pathObject

Returns the value of attribute file_path.



29
30
31
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 29

def file_path
  @file_path
end

#lang_codeObject

Returns the value of attribute lang_code.



29
30
31
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 29

def lang_code
  @lang_code
end

#rowsObject

Returns the value of attribute rows.



29
30
31
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 29

def rows
  @rows
end

Instance Method Details

#processObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/glossarist/agent/iho/bilingual_table.rb', line 36

def process
  # @rows = []
  @rows = BilingualRow.from_csv(IO.read(@file_path))[1..-1]
  @concepts_eng = @rows.map do |bilingual_row|
    SimpleConcept.new(
      lang_code: :eng,
      id: bilingual_row.eng_id.strip,
      term: bilingual_row.eng_term.strip,
      definition: bilingual_row.eng_definition.strip,
    )
  end

  @concepts_other = @rows.map do |bilingual_row|
    SimpleConcept.new(
      lang_code: lang_code,
      id: bilingual_row.other_id.strip,
      term: bilingual_row.other_term.strip,
      definition: bilingual_row.other_definition.strip,
    )
  end
end