Class: InsuranceJP
- Inherits:
-
LucaRecord::Base
- Object
- LucaRecord::Base
- InsuranceJP
- Defined in:
- lib/luca_salary/jp/insurance.rb
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Class Method Summary collapse
Instance Method Summary collapse
- #health_insurance_salary(rank, elder) ⇒ Object
-
#initialize(dir_path, area = nil, date = nil) ⇒ InsuranceJP
constructor
load config.
- #pension_salary(rank) ⇒ Object
- #select_health_insurance(rank) ⇒ Object
- #select_pension(rank) ⇒ Object
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
#table ⇒ Object (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, elder) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/luca_salary/jp/insurance.rb', line 26 def health_insurance_salary(rank, elder) return nil if elder.nil? category = elder ? 'insurance_elder_salary' : 'insurance_younger_salary' round6(select_health_insurance(rank).dig(category)) end |
#pension_salary(rank) ⇒ Object
33 34 35 |
# File 'lib/luca_salary/jp/insurance.rb', line 33 def pension_salary(rank) round6(select_pension(rank).dig('pension_salary')) end |
#select_health_insurance(rank) ⇒ Object
37 38 39 |
# File 'lib/luca_salary/jp/insurance.rb', line 37 def select_health_insurance(rank) @table['fee'].filter{|h| h['rank'] == rank}.first end |
#select_pension(rank) ⇒ Object
41 42 43 |
# File 'lib/luca_salary/jp/insurance.rb', line 41 def select_pension(rank) @table['fee'].filter{|h| h['pension_rank'] == rank}.first end |