Sha256: 226e2618229a3fe988a3ab1f788c48986376f9c25eb9f2a3c75b67d81d642613

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

module Amakanize
  class AuthorName
    class << self
      # @return [Array<Class>]
      def filter_classes
        @filter_classes ||= [
          ::Amakanize::Filters::HtmlUnescapeFilter,
          ::Amakanize::Filters::NormalizationFilter,
          ::Amakanize::Filters::HyphenMinusNormalizationFilter,
          ::Amakanize::Filters::ParenthesesDeletionFilter,
          ::Amakanize::Filters::RoleNameDeletionFilter,
          ::Amakanize::Filters::TrailingAuthorNamePayloadDeletionFilter,
          ::Amakanize::Filters::SpaceDeletionFilter,
        ]
      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

4 entries across 4 versions & 1 rubygems

Version Path
amakanize-0.5.3 lib/amakanize/author_name.rb
amakanize-0.5.2 lib/amakanize/author_name.rb
amakanize-0.5.1 lib/amakanize/author_name.rb
amakanize-0.5.0 lib/amakanize/author_name.rb