Class: InsuranceJP

Inherits:
LucaRecord::Base
  • Object
show all
Defined in:
lib/luca_salary/jp/insurance.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir_path, area = nil, date = nil) ⇒ InsuranceJP

load config



13
14
15
16
17
18
19
# File 'lib/luca_salary/jp/insurance.rb', line 13

def initialize(dir_path, area=nil, date=nil)
  @pjdir = Pathname(dir_path)
  @area = area
  @date = date
  filename = select_active_filename
  @table = self.class.load_table(@pjdir, filename)
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



8
9
10
# File 'lib/luca_salary/jp/insurance.rb', line 8

def table
  @table
end

Class Method Details

.load_table(pjdir, filename) ⇒ Object



21
22
23
24
# File 'lib/luca_salary/jp/insurance.rb', line 21

def self.load_table(pjdir, filename)
  file_path = pjdir / @dirname / filename
  load_data(File.open(file_path))
end

Instance Method Details

#health_insurance_salary(rank) ⇒ Object



26
27
28
# File 'lib/luca_salary/jp/insurance.rb', line 26

def health_insurance_salary(rank)
  round6(select_health_insurance(rank).dig('insurance_elder_salary'))
end

#pension_salary(rank) ⇒ Object



30
31
32
# File 'lib/luca_salary/jp/insurance.rb', line 30

def pension_salary(rank)
  round6(select_pension(rank).dig('pension_salary'))
end

#select_health_insurance(rank) ⇒ Object



34
35
36
# File 'lib/luca_salary/jp/insurance.rb', line 34

def select_health_insurance(rank)
  @table['fee'].filter{|h| h['rank'] == rank}.first
end

#select_pension(rank) ⇒ Object



38
39
40
# File 'lib/luca_salary/jp/insurance.rb', line 38

def select_pension(rank)
  @table['fee'].filter{|h| h['pension_rank'] == rank}.first
end