Sha256: 772dd034c302aac2746a3a70580515b45fa73c00dca0b03db9d5a70024d738b4

Contents?: true

Size: 913 Bytes

Versions: 6

Compression:

Stored size: 913 Bytes

Contents

require "amakanize/filters/base_filter"

module Amakanize
  module Filters
    class TrailingVolumeNumberDeletionFilter < ::Amakanize::Filters::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

6 entries across 6 versions & 1 rubygems

Version Path
amakanize-0.7.0 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.6.5 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.6.4 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.6.3 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.6.2 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
amakanize-0.6.1 lib/amakanize/filters/trailing_volume_number_deletion_filter.rb