Sha256: 7e0a9829fa43680da2c65a938810dd6a2a79c33e0e1abe60c9b7e5fab17e945d

Contents?: true

Size: 739 Bytes

Versions: 6

Compression:

Stored size: 739 Bytes

Contents

require "amakanize/filters/base_filter"

module Amakanize
  module Filters
    class BookPositionInBracketDetectionFilter < ::Amakanize::Filters::BaseFilter
      PATTERN = /
        \(
        (?:#{::Amakanize::PATTERN_OF_PREFIX_OF_BOOK_POSITION})?
        (#{::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_bracket_detection_filter.rb
amakanize-0.6.5 lib/amakanize/filters/book_position_in_bracket_detection_filter.rb
amakanize-0.6.4 lib/amakanize/filters/book_position_in_bracket_detection_filter.rb
amakanize-0.6.3 lib/amakanize/filters/book_position_in_bracket_detection_filter.rb
amakanize-0.6.2 lib/amakanize/filters/book_position_in_bracket_detection_filter.rb
amakanize-0.6.1 lib/amakanize/filters/book_position_in_bracket_detection_filter.rb