Class: Pumi::DataSource::NCDD
- Inherits:
-
Object
- Object
- Pumi::DataSource::NCDD
- Defined in:
- lib/pumi/data_source/ncdd.rb
Defined Under Namespace
Classes: AdministrativeUnit, Misspelling, Row
Constant Summary collapse
- CSV_HEADERS =
%w[type code name_km name_latin reference note1 note2].freeze
- MISSING_DATA =
{ "1715" => { type: "ក្រុង" } }.freeze
- MISSPELLINGS =
[ Misspelling.new(incorrect_text: "Siem Reab", correct_text: "Siem Reap"), Misspelling.new(incorrect_text: "Aoral", correct_text: "Aural"), Misspelling.new(incorrect_text: "Angk Romeas", correct_text: "Angk Romeas"), Misspelling.new(incorrect_text: "Preaek Chrey", correct_text: "Preaek Chrey") ].freeze
- ADMINISTRATIVE_UNITS =
{ "ស្រុក" => AdministrativeUnit.new( en: "District", km: "ស្រុក", latin: "Srok", ungegn: "Srŏk", code_length: 4, group: "districts" ), "ខណ្ឌ" => AdministrativeUnit.new( en: "Section", km: "ខណ្ឌ", latin: "Khan", ungegn: "Khând", code_length: 4, group: "districts" ), "ក្រុង" => AdministrativeUnit.new( en: "Municipality", km: "ក្រុង", latin: "Krong", ungegn: "Krŏng", code_length: 4, group: "districts" ), "ឃុំ" => AdministrativeUnit.new( en: "Commune", km: "ឃុំ", latin: "Khum", ungegn: "Khŭm", code_length: 6, group: "communes" ), "សង្កាត់" => AdministrativeUnit.new( en: "Quarter", km: "សង្កាត់", latin: "Sangkat", ungegn: "Sângkéat", code_length: 6, group: "communes" ), "ភូមិ" => AdministrativeUnit.new( en: "Village", km: "ភូមិ", latin: "Phum", ungegn: "Phum", code_length: 8, group: "villages" ) }.freeze
Instance Attribute Summary collapse
-
#existing_data ⇒ Object
Returns the value of attribute existing_data.
Instance Method Summary collapse
-
#initialize(data_files: default_data_files) ⇒ NCDD
constructor
A new instance of NCDD.
- #load_data!(source_dir: "tmp", output_dir: "data") ⇒ Object
Constructor Details
#initialize(data_files: default_data_files) ⇒ NCDD
Returns a new instance of NCDD.
86 87 88 89 90 |
# File 'lib/pumi/data_source/ncdd.rb', line 86 def initialize(data_files: default_data_files) @existing_data = data_files.each_with_object({}) do |data_file, result| result[data_file.type] = data_file.read end end |
Instance Attribute Details
#existing_data ⇒ Object
Returns the value of attribute existing_data.
84 85 86 |
# File 'lib/pumi/data_source/ncdd.rb', line 84 def existing_data @existing_data end |
Instance Method Details
#load_data!(source_dir: "tmp", output_dir: "data") ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/pumi/data_source/ncdd.rb', line 92 def load_data!(source_dir: "tmp", output_dir: "data") source_files(source_dir).each do |file| parse_source_file(file) end write_data!(output_dir) end |