Sha256: 8e7b9e03bbdff4845402a95bf07e121fec99fba04507407b09ed41522e7babac

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Amakanize
  class SeriesName
    class << self
      # @return [Array<Amakan::Filters::BaseFilter>]
      def filters
        @filters ||= [
          ::Amakanize::Filters::HtmlUnescapeFilter.new,
          ::Amakanize::Filters::NormalizationFilter.new,
          ::Amakanize::Filters::TrailingParenthesesDeletionFilter.new,
          ::Amakanize::Filters::TrailingVolumeNumberDeletionFilter.new,
          ::Amakanize::Filters::TrailingSeriesNamePayloadDeletionFilter.new,
        ]
      end
    end

    # @param raw [String]
    def initialize(raw)
      @raw = raw
    end

    # @note Override
    # def to_s
    #   @raw
    #     .gsub(/[[:space:]]*[\((〈《【「『【[\[〔{\{«‹〘〚].*/, "")
    #     .gsub(/[[:space:]]*通常版/, "")
    #     .gsub(/[[:space:]]+[1-9\d①②③④⑤⑥⑦⑧⑨⑩].*/, "")
    #     .gsub(/[[:space:]]*[1-9\d①②③④⑤⑥⑦⑧⑨⑩]+巻?\z/, "")
    #     .gsub(/[[:space:]]*~.+~/, "")
    #     .gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
    # end

    # @note Override
    def to_s
      self.class.filters.inject(@raw) do |result, filter|
        filter.call(result)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amakanize-0.1.0 lib/amakanize/series_name.rb