Sha256: 7cf5ef5d2b215f6e0859506de1edbcdf3abbd0a07da6b7d2b1fecc33bcc07c22

Contents?: true

Size: 752 Bytes

Versions: 6

Compression:

Stored size: 752 Bytes

Contents

require "amakanize/filters/base_filter"

module Amakanize
  module Filters
    class BookPositionInWordsDetectionFilter < ::Amakanize::Filters::BaseFilter
      PATTERN = /
        (?:#{::Amakanize::PATTERN_OF_PREFIX_OF_BOOK_POSITION})(#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})
        |(#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})(?:#{::Amakanize::PATTERN_OF_SUFFIX_OF_BOOK_POSITION})
      /x

      # @note Override
      def call(context:, output:)
        unless context[:position_detected]
          if position = output[PATTERN, 1]
            context[:position_detected] = true
            output = position
          end
        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/book_position_in_words_detection_filter.rb
amakanize-0.6.5 lib/amakanize/filters/book_position_in_words_detection_filter.rb
amakanize-0.6.4 lib/amakanize/filters/book_position_in_words_detection_filter.rb
amakanize-0.6.3 lib/amakanize/filters/book_position_in_words_detection_filter.rb
amakanize-0.6.2 lib/amakanize/filters/book_position_in_words_detection_filter.rb
amakanize-0.6.1 lib/amakanize/filters/book_position_in_words_detection_filter.rb