Sha256: ba2ab869a9f3e5cdbf1ac99dd84ca9c1b38fd6ea7d1feb8056bb72287619ead5

Contents?: true

Size: 719 Bytes

Versions: 6

Compression:

Stored size: 719 Bytes

Contents

require "amakanize/filters/base_filter"

module Amakanize
  module Filters
    class TrailingDashDeletionFilter < ::Amakanize::Filters::BaseFilter
      TOKENS = %w(
        ̃
        ̰
        ̴
        ‒
        –
        —
        ―
        ⁓
        〜
        〰
        ˜
        ˷
        ~
        ~
        ∼
        ─
      )

      # @note Override
      # @param output [String] e.g. `"アド・アストラ 1 ─スキピオとハンニバル─"`
      # @return [Hash] e.g. `"アド・アストラ 1"`
      def call(context:, output:)
        {
          context: context,
          output: output.gsub(/\s*#{::Regexp.union(TOKENS)}.*/, ""),
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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