<commit_before>require "data/state_pension_date_query"

module SmartAnswer::Calculators
  class StatePensionAgeCalculator
    include FriendlyTimeDiff

    attr_reader :gender, :dob, :qualifying_years, :available_years
    attr_accessor :qualifying_years

    NEW_RULES_START_DATE = Date.parse('6 April 2016')

    def initialize(answers)
      @gender = answers[:gender].to_sym
      @dob = answers[:dob]
      @qualifying_years = answers.fetch(:qualifying_years, 0)
      @available_years = ni_years_to_date_from_dob
    end

    def current_weekly_rate
      @current_weekly_rate ||= SmartAnswer::Calculators::RatesQuery.new('state_pension').rates.weekly_rate
    end

    # Everyone needs 30 qualifying years in all cases - no need to worry about old rules
    def years_needed
      30
    end

    def years_to_pension
      pension_period_end_year(state_pension_date) - pension_period_end_year(Date.today)
    end

    def what_you_get_raw
      if qualifying_years < years_needed
        (qualifying_years.to_f / years_needed.to_f * current_weekly_rate).round(10)
      else
        current_weekly_rate
      end
    end

    # what would you get if all remaining years to pension were qualifying years
    def what_you_would_get_if_not_full<commit_msg>Remove unused calculator method<commit_after>require "data/state_pension_date_query"

module SmartAnswer::Calculators
  class StatePensionAgeCalculator
    include FriendlyTimeDiff

    attr_reader :gender, :dob, :qualifying_years, :available_years
    attr_accessor :qualifying_years

    NEW_RULES_START_DATE = Date.parse('6 April 2016')

    def initialize(answers)
      @gender = answers[:gender].to_sym
      @dob = answers[:dob]
      @qualifying_years = answers.fetch(:qualifying_years, 0)
      @available_years = ni_years_to_date_from_dob
    end

    def current_weekly_rate
      @current_weekly_rate ||= SmartAnswer::Calculators::RatesQuery.new('state_pension').rates.weekly_rate
    end

    # Everyone needs 30 qualifying years in all cases - no need to worry about old rules
    def years_needed
      30
    end

    def years_to_pension
      pension_period_end_year(state_pension_date) - pension_period_end_year(Date.today)
    end

    # what would you get if all remaining years to pension were qualifying years
    def what_you_would_get_if_not_full
{'fraction_non_alphanumeric': 0.06260720411663807, 'fraction_numerical': 0.009433962264150943, 'mean_word_length': 3.8807531380753137, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3400578', 'n_tokens_mistral': 792, 'n_tokens_neox': 719, 'n_words': 164}