Sha256: eeb5498f4e4645c804306319fa5e78f549e331dab5c362547487a0e23ec49201
Contents?: true
Size: 1.38 KB
Versions: 6
Compression:
Stored size: 1.38 KB
Contents
require "amakanize/filters/base_filter" module Amakanize module Filters class ObviousVolumeNumberDeletionFilter < ::Amakanize::Filters::BaseFilter PATTERN = Regexp.union( /\s*#{::Amakanize::PATTERN_OF_VOLUME_PREFIX}?#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}(?:話|巻|版).*/, /\s+#{::Amakanize::PATTERN_OF_VOLUME_PREFIX}?#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}(?:話|巻|版)?:\s+.*/, /\s+#{::Amakanize::PATTERN_OF_VOLUME_PREFIX}#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}\s+.*/, /\s+Lv\.?\s*#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}(?:\s+.*|\z)/, /\s*\(#{::Amakanize::PATTERN_OF_VOLUME_PREFIX}?#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}\).*/, %r<\s*\d+年\s*\d+\s*(?:月|/\d+\s*)号.*>, /\s*\d{4}\s*(?:AUTUMN|SPRING|SUMMER|WINTER)/, /\s*\d+年\s*\d+\s*号.*/, ) # @note Override # @param output [String] e.g. `"刀語 第十一話 毒刀・鍍"`, `"アニウッド大通り 1: アニメ監督一家物語"` # @return [Hash] e.g. `"刀語"`, `"アニウッド大通り"` def call(context:, output:) unless context[:volume_number_removed] output = output.sub(PATTERN) do context[:volume_number_removed] = true "" end end { context: context, output: output, } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems