Sha256: b6d3485dfb10a1494c10696479b8a45ebd2b60b3930963c485643d1d74bd6af2

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

module Amakanize
  class SeriesName
    class << self
      # @return [Array<Class>]
      def filter_classes
        @filter_classes ||= [
          ::Amakanize::Filters::HtmlUnescapeFilter,
          ::Amakanize::Filters::NormalizationFilter,
          ::Amakanize::Filters::ContinuousSpacesNormalizationFilter,
          ::Amakanize::Filters::HyphenMinusNormalizationFilter,
          ::Amakanize::Filters::DashBetweenAlhabetsNormalizationFilter,
          ::Amakanize::Filters::BracketsNormalizationFilter,
          ::Amakanize::Filters::SpacesBetweenExclamationsDeletionFilter,
          ::Amakanize::Filters::SpaceBetweenExclamationAndBracketDeletionFilter,
          ::Amakanize::Filters::ObviousVolumeNumberDeletionFilter,
          ::Amakanize::Filters::TrailingParenthesesDeletionFilter,
          ::Amakanize::Filters::TrailingDashDeletionFilter,
          ::Amakanize::Filters::TrailingSeriesNamePayloadDeletionFilter,
          ::Amakanize::Filters::TrailingVolumeNumberDeletionFilter,
          ::Amakanize::Filters::TrailingSeriesNamePayloadDeletionFilter,
        ]
      end
    end

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

    # @note Override
    def to_s
      filters.inject(context: {}, output: @raw) do |result, filter|
        filter.call(result)
      end[:output]
    end

    private

    def filters
      @filters ||= self.class.filter_classes.map(&:new)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amakanize-0.5.1 lib/amakanize/series_name.rb
amakanize-0.5.0 lib/amakanize/series_name.rb