Class: InsuranceJP

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

load config



10
11
12
13
14
15
# File 'lib/luca_salary/jp/insurance.rb', line 10

def initialize(dir_path, area=nil, date=nil)
  @pjdir = Pathname(dir_path) + 'dict'
  @area = area
  @date = date
  @table = load_table
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

Instance Method Details

#health_insurance_salary(rank) ⇒ Object



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

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

#load_tableObject



17
18
19
20
# File 'lib/luca_salary/jp/insurance.rb', line 17

def load_table
  file_name = @pjdir + select_active_filename
  JSON.parse(File.read(file_name.to_s))
end

#pension_salary(rank) ⇒ Object



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

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

#select_health_insurance(rank) ⇒ Object



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

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

#select_pension(rank) ⇒ Object



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

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