Sha256: 737631a3e45c26ef242010bf72a7dda00ccf62d9645c52695b55b489a592252a

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

require "amakanize/filters/base_filter"

module Amakanize
  module Filters
    class BookPositionAtEndDetectionFilter < ::Amakanize::Filters::BaseFilter
      PATTERN = /
        (?:#{::Amakanize::PATTERN_OF_PREFIX_OF_BOOK_POSITION})?
        (#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})
        (?:#{::Amakanize::PATTERN_OF_SUFFIX_OF_BOOK_POSITION})?
        \s*
        \z
      /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_at_end_detection_filter.rb
amakanize-0.6.5 lib/amakanize/filters/book_position_at_end_detection_filter.rb
amakanize-0.6.4 lib/amakanize/filters/book_position_at_end_detection_filter.rb
amakanize-0.6.3 lib/amakanize/filters/book_position_at_end_detection_filter.rb
amakanize-0.6.2 lib/amakanize/filters/book_position_at_end_detection_filter.rb
amakanize-0.6.1 lib/amakanize/filters/book_position_at_end_detection_filter.rb