Sha256: 8419ac275eade1f7011d9d1d60d6456f8efe53c6759d8aeb9a45c31865f6c859

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

module Amakanize
  module Filters
    class TrailingVolumeNumberDeletionFilter < BaseFilter
      # @note Override
      # @param output [String] e.g. `"やはり俺の青春ラブコメはまちがっている。4"`, `"ネトゲの嫁は女の子じゃないと思った? Lv.2"`
      # @return [Hash] e.g. `"やはり俺の青春ラブコメはまちがっている。"`, `"ネトゲの嫁は女の子じゃないと思った?"`
      def call(context:, output:)
        if !context[:volume_number_removed] && !output.match(/[^\s]Lv\.?\s*#{Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}\z/i)
          output = output.sub(/,?\s*#{PATTERN_OF_VOLUME_PREFIX}?#{Amakanize::PATTERN_OF_NUMERIC_CHARACTERS}(?:話|巻|版)?(?:\s*\(.*?\))?\z/, "")
        end
        {
          context: context,
          output: output,
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
amakanize-0.6.0 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.5.3 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.5.2 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.5.1 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.5.0 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb