Sha256: f36ea3a44e26e586e93a4c4df475aae332f85adcc5b6c22d810d13e6c5bd37e2

Contents?: true

Size: 509 Bytes

Versions: 2

Compression:

Stored size: 509 Bytes

Contents

module ImproveTypography
  module Processors
    class MultiplySign < Processor
      REGEXP = /(\d+|[½⅓¼⅔⅛⅜⅝⅞])(\s*)x(\s*)(\d+|[½⅓¼⅔⅛⅜⅝⅞])/i

      def call
        return str unless multiply_sign
        return str unless str.match?(REGEXP)

        str.gsub(REGEXP, '\1'+multiply_sign+'\4')
      end

      private

      def multiply_sign
        options.fetch(:multiply_sign, I18n.t(:multiply_sign, scope: %i(improve_typography), locale: locale))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
improve_typography-0.1.15 lib/improve_typography/processors/multiply_sign.rb
improve_typography-0.1.14 lib/improve_typography/processors/multiply_sign.rb