Sha256: 28ea1f1f9a40afa597dde626587cc592d8d43825073b40a9e37b50e88f7b6a50
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require 'japanese_calendar/deprecation/reporting' module JapaneseCalendar module Deprecation #:nodoc: all WEEKDAY_DIRECTIVES = { '%Q' => '%JA', '%q' => '%Ja' }.freeze WEEKDAY_PATTERN = Regexp.union(WEEKDAY_DIRECTIVES.keys) private_constant :WEEKDAY_DIRECTIVES, :WEEKDAY_PATTERN # Prepend wrapper for Weekday module module WeekdayWrapper include JapaneseCalendar::Deprecation::Reporting def strftime(format) string = super(format) deprecations = collect_weekday_deprecations(string) deprecations.each { |deprecation| deprecate_directive(*deprecation) } string.gsub(deprecated_weekday_pattern, deprecated_weekday_conversion) end private def collect_weekday_deprecations(format) deprecated_directives = format.scan(WEEKDAY_PATTERN).uniq WEEKDAY_DIRECTIVES.select do |directive, _| deprecated_directives.include?(directive) end end def deprecated_weekday_conversion { '%Q' => weekday_name, '%q' => weekday_abbreviation } end def deprecated_weekday_pattern Regexp.union(deprecated_weekday_conversion.keys) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
japanese_calendar-0.4.2 | lib/japanese_calendar/deprecation/weekday_wrapper.rb |