Sha256: a3c98e247fb20232682628dd6730f56d4719672333489092f42b85268efb6412

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

require 'japanese_calendar/deprecator'

module JapaneseCalendar
  module Weekday
    module Deprecator
      include JapaneseCalendar::Deprecator

      DEPRECATIONS = {
        '%Q' => 'Please use %JA instead.',
        '%q' => 'Please use %Ja instead.'
      }.freeze

      private_constant :DEPRECATIONS

      def strftime(format)
        deprecations = collect_weekday_deprecations(format)
        deprecations.each { |deprecation| deprecate(*deprecation) }
        super(format)
      end

      private

      def collect_weekday_deprecations(format)
        deprecation_pattern = Regexp.union(DEPRECATIONS.keys)
        deprecated_directives = format.scan(deprecation_pattern).uniq
        DEPRECATIONS.select do |directive, _|
          deprecated_directives.include?(directive)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
japanese_calendar-0.4.1 lib/japanese_calendar/weekday/deprecator.rb