Class: TaxJp::LaborInsurances::EmploymentInsuranceDbBuilder

Inherits:
DbBuilder
  • Object
show all
Defined in:
lib/tax_jp/labor_insurances/employment_insurance_db_builder.rb

Instance Attribute Summary

Attributes inherited from DbBuilder

#db_path

Instance Method Summary collapse

Constructor Details

#initialize(db_path = nil) ⇒ EmploymentInsuranceDbBuilder

Returns a new instance of EmploymentInsuranceDbBuilder.



6
7
8
# File 'lib/tax_jp/labor_insurances/employment_insurance_db_builder.rb', line 6

def initialize(db_path = nil)
  super(db_path || TaxJp::LaborInsurances::EmploymentInsurance::DB_PATH)
end

Instance Method Details

#run(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tax_jp/labor_insurances/employment_insurance_db_builder.rb', line 10

def run(options = {})
  with_database(options) do |db|
    header = true
    CSV.foreach(File.join(TaxJp::Utils.data_dir, '労働保険', '雇用保険.tsv'), col_sep: "\t", skip_blanks: true) do |row|
      if header
        header = false
        next
      end
      db.execute(insert_sql, row)
    end
  end
end