module JpEmsFee
Constants
- VERSION
Public Class Methods
africa(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 31 def africa(weight) base(weight, __method__.to_s) end
asia(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 7 def asia(weight) base(weight, __method__.to_s) end
central_america(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 23 def central_america(weight) oceania(weight) end
europa(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 27 def europa(weight) base(weight, __method__.to_s) end
middle_east(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 19 def middle_east(weight) oceania(weight) end
north_america(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 15 def north_america(weight) oceania(weight) end
oceania(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 11 def oceania(weight) base(weight, __method__.to_s) end
south_america(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 35 def south_america(weight) africa(weight) end
Private Class Methods
base(weight, method_name)
click to toggle source
# File lib/jp_ems_fee.rb, line 41 def base(weight, method_name) validate_weight_limit(weight) calculate(weight, method_name) end
calculate(weight, area_name)
click to toggle source
# File lib/jp_ems_fee.rb, line 54 def calculate(weight, area_name) yaml = YAML.load_file(File.expand_path('../../price_table.yaml', __FILE__)) yaml[area_name].each do |r| if r.first >= weight return r[1] end end end
validate_weight_limit(weight)
click to toggle source
# File lib/jp_ems_fee.rb, line 46 def validate_weight_limit (weight) if weight <= 0 raise 'Weight Limit Under' elsif weight > 30000 raise 'Weight Limit Over' end end